redaction

Masks credentials in text bound for logs and error reports.

Error messages often quote whatever a failure carried: an SDK exception that prints the headers it sent, a URL signed for one download, a provider body echoing the key it rejected. redact_secrets masks the credential and keeps the rest, so a message still says what went wrong.

It masks three things:

  • The value of any name=value or name: value pair, quoted or not, whose name marks a credential (api_key, Authorization, X-Amz-Signature, apiKey…). This covers query strings, printed header dicts and plain prose alike. An exception class name followed by its message (KeyError: ...) is not a credential name.

  • A URL’s password (scheme://user:password@host).

  • Tokens recognizable by their format alone: provider key prefixes, AWS access key IDs and JWTs.

pipecat.utils.security.redaction.redact_secrets(text: str) → str[source]

Mask the credentials in text, leaving the rest as written.

Parameters:

text – Text that may quote a credential, such as an error message.

Returns:

The text with each credential replaced by [REDACTED].