fix: isAcknowledged() misses acknowledgments on aws-cdk-lib >=2.262.1 due to prefix casing - #2362
Merged
mergify[bot] merged 1 commit intoAug 4, 2026
Conversation
mrgrain
approved these changes
Aug 4, 2026
mrgrain
force-pushed
the
fix-caseinsenstive-annotations-prefix
branch
from
August 4, 2026 09:56
c7eeb46 to
287d596
Compare
Contributor
Merge Queue Status
This pull request spent 25 seconds in the queue, including 4 seconds running CI. Required conditions to merge
|
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.
NagPack.isAcknowledged() strips a synthetic prefix that aws-cdk-lib's Validations.acknowledge() adds to bare (non-namespaced) rule IDs before writing them to construct metadata, so the stripped key can be compared against the real rule ID (e.g. AwsSolutions-S1).
Through aws-cdk-lib@2.261.0, that prefix was always lowercase annotation::, matching the regex here:
As of aws-cdk-lib@2.262.1, Validations.qualifyId() was refactored to reuse a new shared constant, AnnotationPlugin.RULE_PREFIX = "Annotation" (capitalized), instead of its own internal lowercase constant. The prefix written to metadata is now Annotation::AwsSolutions-S1 instead of annotation::AwsSolutions-S1.
The regex above only matches the lowercase form, so on aws-cdk-lib >=2.262.1 the prefix is never stripped, the key never reduces to the bare rule ID, and Validations.of(construct).acknowledge({ id: "AwsSolutions-S1", ... }) silently stops suppressing anything — no error, the finding just reappears as if never acknowledged.
Compound rule IDs that embed their own :: (e.g. AwsSolutions-IAM5[Action::s3:GetBucket*]) are unaffected — qualifyId() passes those through unqualified because they don't hit the "add a prefix" branch, so this only breaks acknowledgment of simple, colon-free rule IDs like AwsSolutions-S1 or AwsSolutions-IAM4.
Here is a link to the commit that introduced the change in aws-cdk-lib: aws/aws-cdk@75893d9