Skip to content

Redaction

Redact untrusted text before it is included in diagnostics or logs.

redact_text(value, *, limit=None)

Redact common secrets, URLs, and local paths from a text value.

This is suitable for lower-level error messages, tracebacks, and strings written to logs. A length limit is optional so callers can set their own storage boundary without changing the redaction rules.

Parameters:

Name Type Description Default
value str

Text to redact.

required
limit int | None

Maximum output characters before a truncation marker. Defaults to no length limit.

None

Returns:

Type Description
str

The redacted text, optionally bounded to limit characters.

Example

Redact a log message before emitting it.

from gllm_multimodal.utils.redaction import redact_text

print(redact_text("api_key=secret-value"))
Output:
api_key=[REDACTED]