Skip to content

fix(diff): print errors once, from the command, not inline - #597

Merged
jcogilvie merged 1 commit into
mainfrom
print-errors-once
Oct 21, 2026
Merged

jcogilvie merged 1 commit into
mainfrom
print-errors-once

Conversation

@jcogilvie

Copy link
Copy Markdown
Collaborator

Description of your changes

Backports the error-printing rework from crossplane/cli#436 (commit 19817b2, "print errors once, from the command, not inline"). crossplane/cli is importing diff as the baseline for simulate, and this change came out of that work.

Errors were printed in more than one place: the renderers wrote ERROR: lines to stderr, and main printed the returned error again. Now they are printed once, by main:

  • The renderers never write OutputError to stderr. OutputError.FormatError is removed. Warnings still go to stderr when raised.
  • Processors return an error that names each failing resource, and main prints it as Error: %v.
  • main no longer skips IsSchemaValidationError. Otherwise exit code 2 would print nothing.
  • DiffComposition returns the joined per-XR failures (impact analysis failed for N XR(s)) and, only when every composition failed, failed to process all compositions. A partial composition failure still succeeds.
  • Structured output (--output json|yaml) is unchanged: errors[] still carries every error.

The patch could not be applied as-is after #593/#594/#595, so this reimplements its intent against the current architecture.

Tests: renderer tests now assert nothing is written to stderr for errors. Processor tests assert on the returned error. The integration harness prints the returned error as Error: ... into its stderr buffer, as main does, before the stderr assertions. README.md, CLAUDE.md and the design doc are updated to match.

I have:

  • Read and followed Crossplane's contribution process.
  • Run earthly -P +reviewable to ensure this PR is ready for review.
  • Added or updated unit tests.
  • Added or updated integration or e2e tests.
  • Updated documentation as needed (user-facing behavior in README.md; architecture in design/design-doc-cli-diff.md and its diagrams).

Need help with this checklist? See the cheat sheet.

🤖 Generated with Claude Code

The renderers wrote every OutputError to stderr as "ERROR: Kind/name: ...",
and the processors also returned the failure, which main printed again as
"Error: ...". A failing run reported each error twice in two formats.

Stop the renderers printing errors and drop OutputError.FormatError. Structured
output keeps errors[] unchanged, and warnings still go to stderr when raised.
main prints every returned error, schema-validation ones included, since the
renderers no longer print them. DiffComposition now names each failing
resource in its returned error, as PerformDiff already did. The integration
harness prints a returned error as main does so stderr assertions see what a
user sees.

Backport of crossplane/cli#436 (19817b2).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
@jcogilvie
jcogilvie marked this pull request as ready for review October 21, 2026 01:45
@jcogilvie
jcogilvie requested a review from tampakrap as a code owner October 21, 2026 01:45
@jcogilvie
jcogilvie merged commit 8b9d52b into main Oct 21, 2026
14 checks passed
@jcogilvie
jcogilvie deleted the print-errors-once branch October 21, 2026 01:46
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.

1 participant