Skip to content

Commit

Permalink
Merge pull request #11520 from archesproject/jtw/add-json-error-conce…
Browse files Browse the repository at this point in the history
…pt-api

Return JSON response in GET calls to api/concepts #11519
  • Loading branch information
apeters authored Oct 7, 2024
2 parents 5b6aea8 + de71edc commit 621842c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions arches/app/views/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ def get(self, request, conceptid=None):
allowed_formats = ["json", "json-ld"]
format = request.GET.get("format", "json-ld")
if format not in allowed_formats:
return JSONResponse(
return JSONErrorResponse(
status=406,
reason="incorrect format specified, only %s formats allowed"
% allowed_formats,
Expand Down Expand Up @@ -944,13 +944,15 @@ def get(self, request, conceptid=None):

ret.append(concept_graph)
except models.Concept.DoesNotExist:
return JSONResponse(status=404)
return JSONErrorResponse(status=404)
except Exception as e:
return JSONResponse(status=500, reason=e)
return JSONErrorResponse(status=500, reason=e)
else:
return JSONResponse(status=500)
return JSONErrorResponse(status=400)
else:
return JSONResponse(status=500)
return JSONErrorResponse(
status=401 if request.user.username == "anonymous" else 403
)

if format == "json-ld":
try:
Expand All @@ -967,7 +969,7 @@ def get(self, request, conceptid=None):

ret = compact(js, context)
except Exception as e:
return JSONResponse(status=500, reason=e)
return JSONErrorResponse(status=500, reason=e)

return JSONResponse(ret, indent=indent)

Expand Down
1 change: 1 addition & 0 deletions releases/8.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Arches 8.0.0 Release Notes
- Add session-based REST APIs for login, logout [#11261](https://github.com/archesproject/arches/issues/11261)
- Improve handling of longer model names [#11317](https://github.com/archesproject/arches/issues/11317)
- Support more expressive plugin URLs [#11320](https://github.com/archesproject/arches/issues/11320)
- Concepts API no longer responds with empty body for error conditions [#11519](https://github.com/archesproject/arches/issues/11519)

### Dependency changes
```
Expand Down

0 comments on commit 621842c

Please sign in to comment.