Repository navigation
fix: handle SAM RestApi stage references - #4730
Merged
Merged
Conversation
0xTaoZ
force-pushed
the
fix/sam-restapi-stage
branch
from
October 9, 2026 01:36
6b1893b to
7dde3a6
Compare
kddejong
approved these changes
Oct 20, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4730 +/- ##
==========================================
- Coverage 94.72% 94.72% -0.01%
==========================================
Files 439 439
Lines 15840 15858 +18
Branches 3060 3067 +7
==========================================
+ Hits 15005 15021 +16
- Misses 456 457 +1
- Partials 379 380 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #4714.
This updates SAM implicit-resource handling so
AWS::Serverless::StateMachineApievents create the same synthetic implicitServerlessRestApi/stage context as functionApievents. It also teachesFn::Subvalidation that SAM${Api.Stage}references are generated stage-resource references, not CloudFormationFn::GetAttattributes on the API resource.Why
SAM rewrites
${ServerlessRestApi.Stage}to the generated stage logical id during transform. cfn-lint was treating it as a GetAtt againstAWS::Serverless::Api/AWS::ApiGateway::RestApi, causing false positives after the schema-based SAM validation changes.Tests
.venv/bin/python -m pytest test/unit/module/context/test_inject_sam_implicit.py test/unit/rules/functions/test_sub.py -q.venv/bin/python -m pytest test/unit/rules/functions/test_sub.py test/unit/rules/functions/test_getatt.py test/unit/module/context/test_inject_sam_implicit.py -q.venv/bin/ruff check src/cfnlint/context/context.py src/cfnlint/rules/functions/Sub.py test/unit/module/context/test_inject_sam_implicit.py test/unit/rules/functions/test_sub.py.venv/bin/ruff format --check src/cfnlint/context/context.py src/cfnlint/rules/functions/Sub.py test/unit/module/context/test_inject_sam_implicit.py test/unit/rules/functions/test_sub.pygit diff --checkNote: I also tried a CLI smoke with the issue-shaped SAM templates, but this local environment could not download enhanced schemas due to
CERTIFICATE_VERIFY_FAILED, so the focused unit tests are the reliable validation here.Supersedes #4719. The commit and scope are unchanged.