Describe the bug
Running cdk context with no options lists the merged context values, with the header:
Context found in cdk.json:
However, this header is printed even when cdk.json contains no context key at all and every listed value comes from cdk.context.json (and/or ~/.cdk.json). The listing merges the context from all of these files, but the header always names cdk.json.
Implementation: packages/aws-cdk/lib/commands/context.ts prints ioHelper.defaults.info('Context found in %s:', chalk.blue(PROJECT_CONFIG)), where PROJECT_CONFIG is the fixed string 'cdk.json'. There is no per-source information in the listing.
Display-only issue; no functional impact.
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
The header should reflect where the listed context actually comes from, e.g.:
Context found in cdk.context.json:
or, when several files contribute:
Context found in cdk.json, cdk.context.json:
Current Behavior
The header always says Context found in cdk.json:, even when cdk.json has no context.
Reproduction Steps
- In a CDK project, make sure
cdk.json has no context key.
- Create
cdk.context.json with any value, e.g. { "foo": "bar" }.
- Run
cdk context.
The listing shows foo under the header Context found in cdk.json:, although the value is in cdk.context.json.
Possible Solution
The CLI's Configuration already knows which files contributed context. Expose the list of context files that currently contain values, and have the context command render the header from that list (falling back to a generic header when no file source is known).
I will submit a PR for this.
Additional Information/Context
No response
CDK CLI Version
2.1135.0
Framework Version
2.261.0
Node.js Version
24.19.0
OS
macOS 15
Language
TypeScript
Language Version
No response
Other information
No response
Describe the bug
Running
cdk contextwith no options lists the merged context values, with the header:However, this header is printed even when
cdk.jsoncontains nocontextkey at all and every listed value comes fromcdk.context.json(and/or~/.cdk.json). The listing merges the context from all of these files, but the header always namescdk.json.Implementation:
packages/aws-cdk/lib/commands/context.tsprintsioHelper.defaults.info('Context found in %s:', chalk.blue(PROJECT_CONFIG)), wherePROJECT_CONFIGis the fixed string'cdk.json'. There is no per-source information in the listing.Display-only issue; no functional impact.
Regression Issue
Last Known Working CDK Version
No response
Expected Behavior
The header should reflect where the listed context actually comes from, e.g.:
or, when several files contribute:
Current Behavior
The header always says
Context found in cdk.json:, even whencdk.jsonhas no context.Reproduction Steps
cdk.jsonhas nocontextkey.cdk.context.jsonwith any value, e.g.{ "foo": "bar" }.cdk context.The listing shows
foounder the headerContext found in cdk.json:, although the value is incdk.context.json.Possible Solution
The CLI's
Configurationalready knows which files contributed context. Expose the list of context files that currently contain values, and have thecontextcommand render the header from that list (falling back to a generic header when no file source is known).I will submit a PR for this.
Additional Information/Context
No response
CDK CLI Version
2.1135.0
Framework Version
2.261.0
Node.js Version
24.19.0
OS
macOS 15
Language
TypeScript
Language Version
No response
Other information
No response