[Feature] Improve schema error reporting and language translation #112
Labels
project/DACCS
Related to DACCS project (https://github.com/orgs/DACCS-Climate)
triage/feature
New requested feature.
triage/investigate
Exploration tasks or issues requirering more analysis
Context
Since
colander
is used to validate input schemas of requests body and generated responses, it is possible to better handle the returned errors as translated text. Given thatAccept-Language
header is now also supported (#74, #82), we should report invalid inputs messages accordingly in the REST API.More precisely, when a
colander.Invalid
(exception) schema is generated, the responses contain messages asTranslationString
(pyramid.i18n), which can be used to return locale-aware descriptions.See also: https://cornice.readthedocs.io/en/latest/i18n.html
TODO
wps-restapi
portion of the code forcolander.Invalid
and move them to thetween
as a singleHTTPBadRequest
catch. Using a global catch ofcolander.Invalid
, we can run the translation string operations with the full error stack since they are accumulated from the first raised to the top.colander.Invalid
into a specificOWSException
/HTTPException
now provides more details, such as the context where the error happened and specific OGC error codes to use for it. Easier to edit inplace.asdict
or similar variants for error reporting. For the moment, items likeoneOf
aggregates error strings which makes it extremely hard to read. All their errors are dumped in the responsedescription
which is "cleaned", but all the special characters and string concatenation generates a lot of garbage. The description should be replaced by a generic (summary) string, and another field would have the full detail as dict/list.weaver
domain with corresponding message strings for the app.colander
messages are pre-packaged with it. Not only errors should be translated, but as much items as possible such as successful deployment or job status.reference code (minimal - not complete)
The text was updated successfully, but these errors were encountered: