Skip to content

[bug] Keep upstream error content out of logs and traces #615

Open
chethanuk/Switchyard
#9

Description

@afourniernv

Symptom

Upstream errors can contain provider response text. Providers sometimes quote request content in validation errors, so formatting the full error into a log or trace can expose prompts, source code, or other request data.

Parts of this have landed. #611 redacts upstream HTTP bodies from inner call records, #794 covers Advisor fail-open reporting, and #826 covers server request and SSE logs.

One remaining case is ContextWindowExceeded. The HTTP client keeps the provider body in its message, and the client-call observer still formats that error into the span. That can expose request content quoted by the provider.

Expected vs. actual

  • Expected: Keep the complete typed error available for retries, fallback, and the response returned to the caller. Logs and traces should contain only safe structured fields such as the error kind, status, target, and phase.
  • Actual: Context-window failures still reach the client trace through the error's Display output, which includes the upstream message.

Scope notes

Please settle the common logging behavior and apply it consistently to:

  • libsy.client_call, libsy.llm_call, and libsy.run
  • terminal switchyard_server::request events
  • Advisor fail-open warnings and audit events
  • server SSE errors
  • runner and Relay failure reporting

The original error should remain unchanged in flight. Avoid adding another public formatting API unless an external integration needs it. Add regression tests at the final log and trace sinks, not only the inner client span.

#536 and #537 added the typed RouteErrorSummary used by embedded runner integrations. This work should align with that shape where it fits rather than introduce a second string-based contract.

Additional context

Activity

  1. added
    bug
    on Sep 3, 2026
  2. joshuacox commented on Oct 16, 2026

    @joshuacox

    This looks fixed on current main, so it may be closable.

    The sinks named in the scope are covered:

    The typed error itself is unchanged in flight, so retries, fallback, and the response returned to the caller keep the complete error; only the log and trace formatting drops the free-form upstream content in favour of safe structured fields.

    Happy to be corrected if a sink still formats the raw error.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions