You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
The routes in core arches serve a mixture of HTML and JSON. We've generally been using the api/ prefix to clarify which ones should return JSON. Without further configuration, a view or decorator raising an error will return Django's default HTML error responses, which can confuse a client expecting to always parse JSON, as shown below.
Recently written API views have been trying to catch and transform errors to JSON, but this is both verbose and not bullet-proof, e.g. see @group_required decorator below.
Suggest to add custom 400, 403, 404 (maybe) and 500 handlers that sniff for whether it's an api route (prefixed with api/ or api., I guess?) and return JSON instead.
Log in to lingo as tester3/Test12345!
See:
This is because the @group_required decorator on ConceptTreeView (and the others) returns HTML, and we crash on calling .parse()
An alternative to inspecting the route prefix would be to segregate the routes into two python modules and switch on that. We could look into how backward compatible this would be.
The text was updated successfully, but these errors were encountered:
Problem
The routes in core arches serve a mixture of HTML and JSON. We've generally been using the
api/
prefix to clarify which ones should return JSON. Without further configuration, a view or decorator raising an error will return Django's default HTML error responses, which can confuse a client expecting to always parse JSON, as shown below.Recently written API views have been trying to catch and transform errors to JSON, but this is both verbose and not bullet-proof, e.g. see
@group_required
decorator below.Suggest to add custom 400, 403, 404 (maybe) and 500 handlers that sniff for whether it's an api route (prefixed with
api/
orapi.
, I guess?) and return JSON instead.Originally posted by @jacobtylerwalls in archesproject/arches-lingo#86 (comment)
An alternative to inspecting the route prefix would be to segregate the routes into two python modules and switch on that. We could look into how backward compatible this would be.
The text was updated successfully, but these errors were encountered: