Skip to content

code-pipeline: Incorrect double JSON encoding of JSON with tokens #36076

@jnawk

Description

@jnawk

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-codepipelineRelated to AWS CodePipelinebugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions