Open fmigneault opened 6 months ago
The cause is related to this initialization call: https://github.com/Cornices/cornice/blob/abfcfd9eeefaf281237ba84a3b90ef5ee0698aa9/src/cornice/renderer.py#L13-L18
Because the Response.__init__
is called rather than HTTPError.__init__
, not all attributes expected by this class get properly assigned, and notably, the detail
attribute that is defined only under HTTPError
, and not Response
.
@leplatrem Is it possible to see if replacing the base class __init__
call is sufficient to fix this issue?
Somewhat like https://github.com/Cornices/cornice/issues/275, but since it dates from 2015, things changed a lot in the code.
Because
cornice.renderer.JSONError
inherits frompyramid.httpexceptions.HTTPError
, its__str__
implementation looks for thedetail
attribute. A simple logging call such aslogger.info("exception: {!s}", err)
is enough to cause this exception to crash.The
HTTPException
itself the following:So either the JSON
body
could be set todetail
and let it represent it as plain string, or definedetail
/explanation
accordingly with some more explicit message.