Skip to content

fix: evaluate SAM resource dependency cycles before reporting - #4755

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
proton0210:fix/sam-dependency-cycles
Oct 21, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
proton0210:fix/sam-dependency-cycles

Conversation

@proton0210

Copy link
Copy Markdown
Contributor

Closes #4749.

E3004 previously removed SAM edges only after discovering a cycle. That reported the non-SAM portion of false cycles and hid real cycles through SAM resources. Build a separate dependency graph before cycle detection, retaining dependencies of underlying CloudFormation resources and generated execution roles, and excluding properties belonging to separate generated stages, events and deployment preferences.

Cover the three reported templates, independent native cycles, execution-role policies, explicit roles with unused policies, and Ref/GetAtt/Sub/DependsOn self-dependencies. The original graph and template remain available unchanged to other rules.

This remains conservative for dependencies contributed solely by generated event resources; it does not restore the full SAM transform or add a translator dependency.

Validation: 15 focused tests passed, alongside the full unit suite. Three audit passes covered original-source reproduction, non-regression and edge-case checks, and final combined review (3,027 unit/integration tests passed plus the separate schema-updater test; four data tests retain the default exclusion).

@proton0210
proton0210 marked this pull request as draft October 21, 2026 06:07
@proton0210
proton0210 marked this pull request as ready for review October 21, 2026 06:09
@kddejong
kddejong force-pushed the fix/sam-dependency-cycles branch from 2f884a2 to 44eb695 Compare October 21, 2026 17:35
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.17647% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.67%. Comparing base (7fbb68c) to head (44eb695).

Files with missing lines Patch % Lines
src/cfnlint/rules/resources/CircularDependency.py 91.17% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4755      +/-   ##
==========================================
- Coverage   94.68%   94.67%   -0.01%     
==========================================
  Files         439      439              
  Lines       15910    15939      +29     
  Branches     3079     3085       +6     
==========================================
+ Hits        15065    15091      +26     
- Misses        463      465       +2     
- Partials      382      383       +1     
Flag Coverage Δ
unittests 94.67% <91.17%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit 07a22cb into aws-cloudformation:main Oct 21, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E3004: cycles through AWS::Serverless::* resources are misreported since 1.54.0

2 participants