code-pipeline: Incorrect double JSON encoding of JSON with tokens
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
When generating a Code Build project with an embedded Code Build step, with an environment variable whose value is derived from an object with tokens, the value is double encoded, while when doing the same thing from a CDK Pipeline, the value is encoded correctly.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
I expect both mechanisms to emit the same (correct) template fragments.
### Current Behavior
CDK Pipeline emits the correct template snippet, Code Pipeline does not. The Code Pipeline snippet is double encoded.
### Reproduction Steps
Please see sample project here:
https://github.com/jnawk/codepipeline-token-bug
### Possible Solution
CDK Pipeline appears to emit a Code Build resource into the template; Code Pipeline compiles it directly into the pipeline.
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.224.0
### AWS CDK CLI version
2.1031.2 (build 779352d)
### Node.js Version
v22.20.0
### OS
Linux myhostnamehere 6.17.7-300.fc43.x86_64 #1 SMP PREEMPT_DYNAMIC Sun Nov 2 15:30:09 UTC 2025 x86_64 GNU/Linux
### Language
TypeScript
### Language Version
Typescript ~5.9.3
### Other information
The sample project has the synthesised stack included in the cdk.out. (I did the .gitignore gymnastics to make that happen).
The Analytics metadata has been manually snipped because I CBF figuring out what's in it and it's not an intrinsic part of the problem.
Contributor guide
Research direction
Start with the linked sample project and its synthesized stack in cdk.out; run the reproduction and compare the Code Build project embedded through Code Pipeline with the equivalent CDK Pipeline output. Trace how the environment-variable value derived from tokenized objects is emitted, and consider the issue done when both mechanisms produce the same correctly encoded template fragment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100