Skip to content

fix: keep diagnostics off stdout for structured output#786

Merged
mcncl merged 2 commits intobuildkite:mainfrom
mtibben:mtibben/fix-structured-output-stderr
Apr 15, 2026
Merged

fix: keep diagnostics off stdout for structured output#786
mcncl merged 2 commits intobuildkite:mainfrom
mtibben:mtibben/fix-structured-output-stderr

Conversation

@mtibben
Copy link
Copy Markdown
Contributor

@mtibben mtibben commented Apr 15, 2026

Support machine-readable CLI output by keeping diagnostics off stdout.

Structured output commands currently print warnings and empty-state messages to stdout, which breaks callers that expect stdout to contain only JSON or YAML. Browser-open failures also use stdout even though they are diagnostics.

This routes shared warnings to stderr and makes JSON- and YAML-capable commands return structured empty values when no resources are found. It also adds focused regression coverage around the shared output helper and configuration validation warning so structured output stays clean.

@mtibben mtibben requested review from a team as code owners April 15, 2026 03:17
@mtibben mtibben force-pushed the mtibben/fix-structured-output-stderr branch from d9be599 to 7a5fda0 Compare April 15, 2026 03:20
Comment on lines +64 to +68
stdout, stderr := captureStandardStreams(t, func() {
if err := ValidateConfiguration(conf, "pipeline view"); err != nil {
t.Fatalf("expected no error when only org is missing, got %v", err)
}
})
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.

Suggested change
stdout, stderr := captureStandardStreams(t, func() {
if err := ValidateConfiguration(conf, "pipeline view"); err != nil {
t.Fatalf("expected no error when only org is missing, got %v", err)
}
})
var validationErr error
stdout, stderr := captureStandardStreams(t, func() {
validationErr = ValidateConfiguration(conf, "pipeline view")
})
if validationErr != nil {
t.Fatalf("expected no error when only org is missing, got %v", validationErr)
}

Kind of nitty, but if the output of the tests is redirected to a pipe then the output might be lost.

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.

Addressed in 1dde33b

Copy link
Copy Markdown
Contributor

@mcncl mcncl left a comment

Choose a reason for hiding this comment

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

Super minor thing which is more house-keepy than anything, but happy to approve/merge.

@mcncl mcncl merged commit 94602ac into buildkite:main Apr 15, 2026
3 checks passed
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