[cubicweb.web] Cannot show the error banner when an error occurs with the form validation after a redirection
Description
During the validation of a CubicWeb web form, a redirection (cubicweb.web._exceptions.Redirect
) have been raised by the backend, followed by the unknown error requests.exceptions.MissingSchema
.
This behavior was catch by the _validate_form
method and it try the following code:
except Exception as ex:
req.cnx.rollback()
req.exception("unexpected error while validating form")
return (False, str(ex).decode("utf-8"), ctrl._edited_entity)
Since it tried to decode a string, another exception was raised, and the form was never validate (and there is no banner to show why).
Traceback
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/pyramid/tweens.py", line 41, in excview_tween
response = handler(request)
File "/usr/lib/python3.9/site-packages/cubicweb/pyramid/bwcompat.py", line 283, in __call__
response = self.cwhandler(request)
File "/usr/lib/python3.9/site-packages/cubicweb/pyramid/bwcompat.py", line 172, in __call__
content = controller.publish(rset=rset)
File "/usr/lib/python3.9/site-packages/cubicweb/web/views/basecontrollers.py", line 273, in publish
status, args, entity = _validate_form(self._cw, self._cw.vreg)
File "/usr/lib/python3.9/site-packages/cubicweb/web/views/basecontrollers.py", line 234, in _validate_form
return (False, str(ex).decode("utf-8"), ctrl._edited_entity)
AttributeError: 'str' object has no attribute 'decode'
Metadata
- Python: 3.9.10
- Cubicweb: 3.37.2