Skip to content

fix(toolkit-lib): paginate stack resource drift results - #2028

Open
proton0210 wants to merge 1 commit into
aws:mainfrom
proton0210:fix/drift-result-pagination
Open

proton0210 wants to merge 1 commit into
aws:mainfrom
proton0210:fix/drift-result-pagination

Conversation

@proton0210

Copy link
Copy Markdown
Contributor

Issue

Closes #2026.

Change

detectStackDrift now consumes every DescribeStackResourceDrifts page before formatting results and counting drifted/unchecked resources. It follows continuation tokens even when a page has an empty or omitted resource list, preserves all statuses (including UNKNOWN), and does not return an obsolete continuation token. A later-page API failure propagates instead of reporting partial success.

This fixes false-negative cdk drift --fail results for larger stacks without changing command options, formatting, IAM permissions, or single-page behavior.

Validation

  • Toolkit library and CLI TypeScript compilation passed.
  • Drift API/action suites: 33 tests passed, including 100 first-page records followed by an empty page and later DELETED/UNKNOWN records, correct request tokens, warning output, and later-page failures.
  • Existing CLI drift exit-code tests: 2 passed.
  • Toolkit library ESLint passed; git diff --check clean.
  • Three audit passes covered API pagination/error behavior, regression tests and CLI exit-code wiring, and final scope/backward compatibility.
  • No AWS deployment performed; AWS responses are mocked in these tests.

No feature flag is proposed: incomplete API pagination is an erroneous result, not an intended alternate behavior.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.00%. Comparing base (13877dc) to head (4fbe443).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2028      +/-   ##
==========================================
+ Coverage   91.96%   92.00%   +0.03%     
==========================================
  Files          82       82              
  Lines       13138    13138              
  Branches     1864     1866       +2     
==========================================
+ Hits        12083    12087       +4     
+ Misses       1017     1013       -4     
  Partials       38       38              
Flag Coverage Δ
suite.unit 92.00% <ø> (+0.03%) ⬆️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch is waiting to be deployed

1 active and 1 waiting deployments
integ-approval — 4fbe443c Waiting Oct 8, 2026 by proton0210 via prepare #7122
automation — 4fbe443c Deployed Oct 8, 2026 by proton0210 via Set AutoQueue on PR #2028 #3706
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(drift): cdk drift misses drift on stacks with more than 100 resources (DescribeStackResourceDrifts not paginated)

2 participants