Skip to content

OpenSecret: log bounded, sanitized upstream inference error details #970

Closed

Description

@AnthonyRonning

Upstream inference failures currently retain status and selected safe headers but discard the response body. An HTTP 400 therefore cannot be distinguished as a context-limit error, unsupported parameter, malformed tool history, or another provider rejection using the existing execution diagnostics.

Add a short, sanitized upstream error message summary or snippet, plus an error code/type when available, correlated with the existing request, execution, attempt, provider, model, and HTTP-status metadata.

Scope and acceptance criteria

  • Read only a bounded prefix of non-success inference responses, with explicit byte and time limits. Handle both attested and standard provider transports through the existing provider boundary.
  • Prefer allowlisted structured error fields. Sanitize and truncate the message; never log raw bodies, echoed prompts/responses, tool arguments, credentials, headers, or other customer content. Use a safe category/code-only fallback when a message cannot be safely summarized. Strip control characters to prevent log injection.
  • Record whether diagnostics were truncated, unavailable, or unparseable. Empty, oversized, non-JSON, invalid-encoding, stalled, and interrupted bodies must still produce the original provider failure promptly.
  • Diagnostic collection must preserve cancellation, one terminal outcome, status/Retry-After classification, circuit signals, usage accounting, and existing client-visible error contracts. Do not introduce inference replay or provider retries.
  • Add focused tests for useful sanitized diagnostics and the privacy/resource boundaries above, including provider error messages that echo sensitive input.
  • Update relevant logging guidance narrowly to distinguish safe extracted diagnostics from prohibited raw provider-body logging.

Starting points: try_provider, attempt_failure_from_provider_error, and log_attempt_terminal in services/opensecret/src/web/openai.rs; UpstreamProviderError and the response abstraction in services/opensecret/src/provider_client.rs.

The current discard behavior is explicit in the provider error path. This issue improves diagnostics; it does not presume that an upstream 400 is a routing defect.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions