Skip to content

fix(cli): cdk list pollutes stdout with synthesis time in CI#1663

Draft
sai-ray wants to merge 9 commits into
mainfrom
sai/fix-cdk-list-synth-time-ci
Draft

fix(cli): cdk list pollutes stdout with synthesis time in CI#1663
sai-ray wants to merge 9 commits into
mainfrom
sai/fix-cdk-list-synth-time-ci

Conversation

@sai-ray

@sai-ray sai-ray commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

cdk ls prints status lines like ✨ Synthesis time: X.XXs and Including dependency stacks: ... alongside the stack listing. In CI these go to stdout, next to the listing, which breaks scripts that parse the output (issue aws/aws-cdk#38165).

#1637 tried to fix this by suppressing the synth-time message under --json, but plain cdk ls in CI was still affected, and the dependency line was never handled.

These status lines are info-level. While listing, the log level is raised to warn so only the listing (a result message) and errors get through. This applies in all cases, not just CI or --json.

Tests

  • Unit: the log level is raised to warn during listing and restored afterwards, including when listing throws.
  • Integ: cdk ls and cdk ls <stack-with-dependency> in CI produce only the stack listing, no status lines.

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Comment thread packages/aws-cdk/lib/cli/cdk-toolkit.ts Outdated
// In CI, info-level output (incl. the synth-time line, I1000) routes to stdout next to the
// listing and breaks parsers. With --json, stdout is an explicit machine-readable contract.
// In both cases, suppress I1000 so stdout carries only the listing.
if (options.json || this.ioHost.isCI) {

@mrgrain mrgrain Jun 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just disable them for any case please. Let us not get confused by reports saying this happens in CI. It happens everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted to draft while I rework this.

The current approach raises the log level to warn during listing. It works, but it's pretty blunt, it mutates shared ioHost state and ends up swallowing other info output during the call too.

So I was thinking of giving the "Including dependency stacks" line its own message code. Then I'd suppress that and the synth-time line by code on the list path. Feels self contained and matches what we already do. Does that sound right to you, would you go about it differently?

Comment thread packages/aws-cdk/lib/cli/cdk-toolkit.ts Outdated
// listing and breaks parsers. With --json, stdout is an explicit machine-readable contract.
// In both cases, suppress I1000 so stdout carries only the listing.
if (options.json || this.ioHost.isCI) {
this.ioHost.once(IO.CDK_TOOLKIT_I1000, () => ({ preventDefault: true }));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am CERTAIN there is a second message we need to silence as well.

github-actions Bot and others added 5 commits June 24, 2026 00:54
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

@mrgrain mrgrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggle understanding what we are trying to achieve here. Can you please structure the PR to show relevant screenshots of the pre #1603 output (have one for every mode you are interested in) and than include screenshots of today's output.

This way it will be abundantly clear which messages got introduced and how this PR is fixing it.

this.ioHost.once(IO.CDK_TOOLKIT_I1000, () => ({ preventDefault: true }));
// Only the listing should reach stdout; drop info status lines (synth time, dependency notes).
const previousLevel = this.ioHost.logLevel;
this.ioHost.logLevel = 'warn';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem like the right approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants