Skip to content

Provider errors do not redact custom header credentials or a bare custom auth token #1210

Open

Description

@Vasanthdev2004

The native providers under internal/providers (openai, gemini and the third one) redact error text with providerio.Redact(message, provider.apiKey, provider.authHeaderValue) and nothing else (each package's redact in provider.go). Two kinds of configured credential are not in that set:

  • customHeaders values. A profile can send a credential in a custom header, for example X-Api-Key. If the server or a proxy in front of it echoes that value in an error body, the provider's error keeps it: ClassifiedError builds the message from the body for every status, and the same text is shown to the user and persisted in the session log as the error event's message (and as cause once Persist status code and cause on provider error events (#674) #882 lands).
  • The token inside a custom auth header value. authHeaderValue is matched whole, so with a value like Token abc... an error that quotes only the token keeps it. The Bearer heuristic only applies when the word Bearer precedes the token in the message.

providerhealth already handles both: its providerSecrets adds every non-blank custom header value and the second field of the auth header value, and runs them through redaction.RedactString as ExtraSecretValues. The providers should use the same set, so the shown message, the persisted message and the cause agree. A regression test per provider should echo a custom header value and the bare auth token in an error body and assert neither survives, including a value split by a control byte, which redaction.RedactString already handles for ExtraSecretValues.

Found while reviewing CodeRabbit's note on #882, which persists the provider's raw cause next to the message. The gap is older than #882: the persisted message already carries the same body on every status except the upstream-unreachable case.

Activity

  1. added
    bug
    on Nov 9, 2026
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