Skip to content

DO-2060: strip ANSI colour codes from the CDK diff output - #210

Merged
tmthrgd-aligent merged 1 commit into
mainfrom
fix/DO-2060_strip_ansi_color_codes
Nov 20, 2026
Merged

tmthrgd-aligent merged 1 commit into
mainfrom
fix/DO-2060_strip_ansi_color_codes

Conversation

@tmthrgd-aligent

Copy link
Copy Markdown
Contributor

Description of the proposed changes

Context

When diff-command runs through Nx, the CDK diff output keeps its ANSI colour codes even with --no-color. Nx runs tasks in a pseudo-terminal, targets with "color": true set FORCE_COLOR, and Nx colours its own lines too. The codes end up in deployment-diff.txt, the PR comment and the GitHub notification emails, making them hard to read (see aligent/opal-fibre-int#15).

Changes

Strip colour from the CDK diff in aws-cdk.yml, so every caller is fixed without changing each Nx project's config:

  • Set FORCE_COLOR=0 and NO_COLOR=1 on the "Generate deployment diff" step, to stop most colour at the source.
  • Strip any ANSI escape codes that are left from diff_output with sed, before it's written to deployment-diff.txt and checked with grep. This also stops a colour code from breaking the "There were no differences" check.

Test

  • In an ubuntu:24.04 container, run the sed line on sample output containing bold, colour, reset and clear-line codes. Check that no escape characters are left and the text is unchanged.
  • Run the PR diff from an Nx project (e.g. opal-fibre-int) against this branch. Check that the PR comment and email are plain text.

Screenshots (if applicable)

Other solutions considered (if any)

  • Add a ci configuration with "color": false to each Nx project (aligent/opal-fibre-int#15): this works, but needs a change in every Nx project, and any project that misses it still has the problem. It also doesn't remove Nx's own colour codes.
  • Keep the raw output for the echo to the step log: the Actions log renders ANSI codes as colour, so only the diff file and the grep checks need the stripped text. Not done, because with FORCE_COLOR=0 set, the only colour left to keep would come from Nx targets with color: true.

Notes to PR author

  • ⚠️ Please make sure the changes adhere to the guidelines mentioned in our contribution guide.

Notes to reviewers

  • ℹ️ When you've finished leaving feedback, please add a final comment to the PR tagging the author, letting them know that you have finished leaving feedback

Time Tracking

  • DO-2060: code review, select project XXXX

🤖 Generated with Claude Code

When diff-command runs through Nx, CDK can still output colour even with
--no-color. Nx runs tasks in a pseudo-terminal, and targets with
"color": true set FORCE_COLOR. Nx also colours its own lines. The escape
codes ended up in deployment-diff.txt, the PR comment and the GitHub
notification emails.

Set FORCE_COLOR=0 and NO_COLOR=1 on the diff step to stop most colour at
the source, then strip any escape codes that are left with sed. This
fixes every caller without changing each Nx project's config. It also
stops a colour code from breaking the "There were no differences" check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmthrgd-aligent
tmthrgd-aligent merged commit 4e63d69 into main Nov 20, 2026
3 checks passed
@tmthrgd-aligent
tmthrgd-aligent deleted the fix/DO-2060_strip_ansi_color_codes branch November 20, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants