Keep the API key out of %#v for redacted LLM errors
The OpenAI adapter's redactedError had no GoString, so %#v printed its fields, including the raw API key. Add GoString returning the redacted text, matching the Anthropic adapter; redactedJoin inherits it. Add TestRedactedErrorsFormatWithoutKey to both adapters, formatting redactedError, redactedJoin and transportFailure with %v, %+v and %#v. llm.ProviderError and llm.RateLimitedError keep no secret and are already covered by TestTypedErrorsDoNotKeepSecret. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -530,6 +530,9 @@ type redactedError struct {
|
||||
|
||||
func (e *redactedError) Error() string { return e.text }
|
||||
|
||||
// GoString keeps %#v from printing the fields, which hold the key.
|
||||
func (e *redactedError) GoString() string { return e.text }
|
||||
|
||||
func (e *redactedError) Unwrap() error { return redact(errors.Unwrap(e.err), e.key) }
|
||||
|
||||
func (e *redactedError) Is(target error) bool { return errors.Is(e.err, target) }
|
||||
|
||||
Reference in New Issue
Block a user