Skip to content

Print errors once, not per span level#3592

Open
kichristensen wants to merge 2 commits into
getporter:mainfrom
kichristensen:duplicateError
Open

Print errors once, not per span level#3592
kichristensen wants to merge 2 commits into
getporter:mainfrom
kichristensen:duplicateError

Conversation

@kichristensen
Copy link
Copy Markdown
Contributor

@kichristensen kichristensen commented May 17, 2026

What does this change

Errors in Porter were printed multiple times to the console — once per call stack layer — because TraceLogger.Error() wrote to both the OTel span and the Zap console logger, and error wrapping caused each layer to re-log the growing chain:

error: exit status 1
error: running script: exit status 1
error: running bundle: running script: exit status 1

This PR removes the Zap logger call from TraceLogger.Error() so it only records to the OTel span. Both cmd/porter/main.go and cmd/exec/main.go now print the final error to stderr exactly once after the command fails.

The rule is now clear:

  • log.Error(err) — records to telemetry/tracing only, no console output
  • log.Debug/Info/Warn — prints to console and records to span
  • main.go — sole place that prints the final error to the user

The long-disabled TestCLI integration test is re-enabled.

The new error output will look like this:

$ porter explain -r=[ghcr.io/getporter/missing-bundle

unable to pull bundle: failed to resolve bundle manifest "ghcr.io/getporter/missing-bundle": object required

instead of the the current:

$ porter explain -r=[ghcr.io/getporter/missing-bundle

unable to pull bundle: failed to resolve bundle manifest "ghcr.io/getporter/missing-bundle": object required
unable to pull bundle: failed to resolve bundle manifest "ghcr.io/getporter/missing-bundle": object required

What issue does it fix

Closes #3355
Closes #2278

Notes for the reviewer

Issue #2284 proposed adding a new span-without-logger API. This PR takes a simpler approach: remove console output from Error() entirely and let main own the user-facing error print. No new API surface, no call-site changes needed.

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

Remove console logging from TraceLogger.Error() so errors are
only recorded to the OTel span. main.go (porter and exec) now
prints the final error to stderr exactly once after command
execution fails, eliminating the repeated/growing error chain
visible in the CLI output.

Re-enable TestCLI integration test.

Fixes getporter#3355, getporter#2278

Signed-off-by: Kim Christensen <kimworking@gmail.com>
@kichristensen kichristensen changed the title fix: print errors once, not per span level Print errors once, not per span level May 17, 2026
Errors are now written to the zap logger (file sink) but
suppressed from the console sink; main.go still prints
the final error once to stderr.

Plugin logger also excludes error level since plugins
communicate errors via return values.

Update golden files and test expectations accordingly.

Signed-off-by: Kim Christensen <kimworking@gmail.com>
@kichristensen kichristensen marked this pull request as ready for review May 17, 2026 21:07
@kichristensen kichristensen requested a review from a team as a code owner May 17, 2026 21:07
Comment thread pkg/portercontext/context_test.go
Writing logs to /.porter/logs/0.json
a thing happened
a weird thing happened
a bad thing happened
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still believe these should be capture-able, are they no longer so?

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.

Errors are still captured to the log file, but not by the console per-span. This file only tracks console output, the error is shown once, printed by main.go

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.

Porter default error messages are too verbose for an installer experience Only print error messages once to the console

2 participants