Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc API fixes #889

Merged
merged 8 commits into from
Sep 9, 2023
Merged

Misc API fixes #889

merged 8 commits into from
Sep 9, 2023

Conversation

rabstejnek
Copy link
Collaborator

Some 500 errors were reported during our API scan as follows:

  • TypeError at /epi/api/group/
    • Request Method: POST
    • Exception Type: TypeError
    • Exception Value: 'bool' object is not iterable
    • Exception Location: /usr/local/lib/python3.11/site-packages/hawc/apps/common/serializers.py, line 281, in to_internal_value
  • TypeError at /epi/api/group-result/
    • Request Method: POST
    • Exception Type: TypeError
    • Exception Value: 'bool' object is not iterable
    • Exception Location: /usr/local/lib/python3.11/site-packages/hawc/apps/common/serializers.py, line 281, in to_internal_value
  • KeyError at /ani/api/animal-group/ 'dose_units_id'
    • Request Method: POST
    • Exception Type: KeyError
    • Exception Value: 'dose_units_id'
    • Exception Location: /usr/local/lib/python3.11/site-packages/hawc/apps/animal/serializers.py, line 116, in
    • Raised during: hawc.apps.animal.api.AnimalGroup
      • /usr/local/lib/python3.11/site-packages/hawc/apps/animal/serializers.py, line 116, in
      • units = set([d["dose_units_id"] for d in doses])

The first two errors stemmed from the same bug; we were iterating over data before determining if it was iterable.
The third error occurred when a dose_unit_id was not given for a dose; this was fixed by making dose_unit_id required when deserializing dose data.

@rabstejnek rabstejnek marked this pull request as ready for review August 29, 2023 21:40
Copy link
Owner

@shapiromatron shapiromatron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - since you converted the custom validation code to a serializer.Field, I took advantage of that downstream when validating the Dose Regime and removed a little more custom code.

@shapiromatron shapiromatron merged commit 176bea6 into main Sep 9, 2023
@shapiromatron shapiromatron deleted the misc-api-fixes branch September 9, 2023 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants