fix(toolkit-lib): fail gc on ECR tagging permission errors - #1828
Open
lemon0333 wants to merge 1 commit into
Open
fix(toolkit-lib): fail gc on ECR tagging permission errors#1828lemon0333 wants to merge 1 commit into
lemon0333 wants to merge 1 commit into
Conversation
parallelTagEcr caught every error from ecr:PutImage, intending to ignore the benign imageTag-collision false negative that self-heals on the next run. It also swallowed AccessDeniedException, so a role missing the ecr:PutImage permission made cdk gc silently no-op and never report a failure. Rethrow on access-denied errors (via the existing isAccessDeniedError helper) so the command fails as expected, while still ignoring the collision false negative. Fixes aws#347
aws-cdk-automation
enabled auto-merge
August 13, 2026 07:49
lemon0333
requested a deployment
to
integ-approval
August 13, 2026 07:49 — with
GitHub Actions
Waiting
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.
Fixes #347
parallelTagEcrin toolkit-lib'sgarbage-collector.tscaught every error fromecr:PutImage. The intent was to ignore the benign imageTag-collision false negative (the isolated asset simply gets tagged on the next run), but it also swallowedAccessDeniedException. As a result, when the role is missing theecr:PutImagepermission,cdk gcsilently no-ops — no images are tagged or deleted, yet the command reports success.This change rethrows on access-denied errors (using the existing
isAccessDeniedErrorhelper, which already handles theAccessDenied/AccessDeniedExceptionphrasing differences across services), socdk gcfails as expected on a permission problem. The benign collision case is still ignored.Verified with a new unit test in
garbage-collection.test.ts(ecr:PutImagerejects withAccessDeniedException→garbageCollect()rejects); the full garbage-collection suite passes (29/29).Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license