fix(cli): cdk context header always claims the context was found in cdk.json - #1816
Open
go-to-k wants to merge 1 commit into
Open
fix(cli): cdk context header always claims the context was found in cdk.json#1816go-to-k wants to merge 1 commit into
go-to-k wants to merge 1 commit into
Conversation
go-to-k
requested a deployment
to
integ-approval
August 11, 2026 11:50 — with
GitHub Actions
Waiting
aws-cdk-automation
enabled auto-merge
August 11, 2026 11:50
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1816 +/- ##
==========================================
- Coverage 90.32% 90.31% -0.02%
==========================================
Files 80 80
Lines 12124 12149 +25
Branches 1716 1723 +7
==========================================
+ Hits 10951 10972 +21
- Misses 1139 1143 +4
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 #1814
Problem
cdk contextlists the merged context fromcdk.json,cdk.context.jsonand~/.cdk.json, but the listing header is hardcoded toContext found in cdk.json:(PROJECT_CONFIG). Whencdk.jsonhas nocontextkey and all values come fromcdk.context.json, the header points the user at the wrong file.Fix
Configuration(which builds the context from its sources) now exposescontextSourceFiles: the names of the context files that currently contain at least one value, in lookup precedence order.contextcommand renders the header from that list, e.g.Context found in cdk.context.json:orContext found in cdk.json, cdk.context.json:. When no file source is known (e.g. context passed only on the command line), it falls back to a genericContext found:header.The change is contained in the
aws-cdkpackage; theContextclass intoolkit-lib(not part of its public API) is unchanged.Testing
test/cli/user-config.test.ts:contextSourceFileslists all ofcdk.json/cdk.context.json/~/.cdk.jsonwhen each contains context, and omits files without context values (e.g. acdk.jsonthat has settings but nocontextkey).test/commands/context-command.test.ts: the listing header names the provided source files, and falls back to the generic header when the sources are unknown.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license