Never print a body that has no message in an error
Merged
AL
3d ago+115+115+012345678901234567890123456789-5-5-0123456789
An ApiError whose answer carried no message quoted the whole body. The sub-user payload holds proxy_password, so an answer with success: false, an empty description and that payload put the live proxy password into the error text.
The text now comes only from detail, message, error, description, errors or field errors ({field: [message]}); any other body is described by its key names. Tests cover the success=false envelope, an error object without a message and a list of objects. Version 0.1.7.
Summary by cubic
Stops ApiError from printing a response body into the error text when the body has no message, preventing the sub-user payload's proxy_password from leaking into logs.
- Text comes only from
detail,message,error,description,errors, or field errors ({field: [message]}), or from a body that is itself a string or a list of non-empty strings; anerrorsvalue is printed only when it holds messages or a field mapped to them. - Empty strings and lists mixing strings with objects are never printed; anything else is described by shape, as in
no message in the answer (keys: description, errors, payload, success)orno message in the answer (a list of 2). ApiError.bodystill holds the raw answer and can carry credentials, so callers must not log it.- Tests cover the
success: falseenvelope, an error object without a message, a nestederrorsbody, lists mixing strings and objects, and empty-string items. Version 0.1.7.
Summary by CodeRabbit
- Bug Fixes
- API errors now use recognized messages when available and otherwise describe the response structure, avoiding exposure of sensitive values in error messages.
- Documentation
- Clarified that error response bodies may contain credentials and should not be logged.
- Chores
- Updated the release version to 0.1.7.