Skip to content

fix(cli): reject non-numeric ids in cdk acknowledge - #1844

Merged
aws-cdk-automation merged 1 commit into
aws:mainfrom
lemon0333:fix/ack-reject-non-numeric-id
Aug 18, 2026
Merged

fix(cli): reject non-numeric ids in cdk acknowledge#1844
aws-cdk-automation merged 1 commit into
aws:mainfrom
lemon0333:fix/ack-reject-non-numeric-id

Conversation

@lemon0333

Copy link
Copy Markdown
Contributor

Fixes #248

cdk acknowledge <id> ran its argument through Number(), so a scoped construct warning id such as @aws-cdk/aws-ecs:minHealthyPercent became NaN and was serialized as null into acknowledged-issue-numbers in cdk.context.json — corrupting the file, while the warning still displayed.

cdk acknowledge is for numeric notice IDs; scoped construct warnings are acknowledged in code via Annotations.of(scope).acknowledgeWarning('<id>'). This validates the id is a numeric notice id and fails fast with a clear, actionable error instead of silently writing null:

Invalid notice ID '@aws-cdk/aws-ecs:minHealthyPercent': 'cdk acknowledge' only accepts numeric notice IDs (e.g. 'cdk acknowledge 12345'). Scoped construct warnings such as '@aws-cdk/aws-ecs:minHealthyPercent' are acknowledged in code with Annotations.of(scope).acknowledgeWarning('<id>').

Numeric IDs are unchanged. Added unit tests (a scoped id throws and leaves the context uncorrupted; a non-numeric id throws) — acknowledge.test.ts passes (3/3).

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

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

`cdk acknowledge <id>` ran the argument through `Number()`, so a scoped
construct warning id like `@aws-cdk/aws-ecs:minHealthyPercent` became `NaN`
and was serialized as `null` into `acknowledged-issue-numbers` in
cdk.context.json, corrupting the file while the warning still showed.

Validate that the id is a numeric notice id and fail fast with a clear error
otherwise, pointing users to acknowledge scoped construct warnings in code via
`Annotations.of(scope).acknowledgeWarning()`.

Fixes aws#248
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.33%. Comparing base (536ad69) to head (ef5bd4f).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1844   +/-   ##
=======================================
  Coverage   90.32%   90.33%           
=======================================
  Files          80       80           
  Lines       12124    12134   +10     
  Branches     1716     1718    +2     
=======================================
+ Hits        10951    10961   +10     
  Misses       1139     1139           
  Partials       34       34           
Flag Coverage Δ
suite.unit 90.33% <100.00%> (+<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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aws-cdk-automation
aws-cdk-automation added this pull request to the merge queue Aug 18, 2026
Merged via the queue into aws:main with commit c71ab23 Aug 18, 2026
21 of 22 checks passed
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.

cli: cdk ack doesn't work correctly for @aws-cdk-scoped warnings

4 participants