-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
fix(annotations): handle required fields properly #17234
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17234 +/- ##
==========================================
- Coverage 76.82% 76.75% -0.08%
==========================================
Files 1038 1037 -1
Lines 55597 55609 +12
Branches 7585 7588 +3
==========================================
- Hits 42715 42680 -35
- Misses 12632 12679 +47
Partials 250 250
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
0617638
to
8feedc1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
required=True, | ||
allow_none=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required=True
only makes sure the property is defined, so here we need to also add allow_none=False
to make sure null
values aren't accepted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks for the comprehensive unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for fixing this!
@@ -0,0 +1,157 @@ | |||
# Licensed to the Apache Software Foundation (ASF) under one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we place these on tests/unit_tests/annotation_layers
instead? they seem more like unit tests then integration tests. It would be nice also to place a test on the API integration tests that would fail on current master but succeed on this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment @dpgaspar - you're absolutely right, these should have been placed on the unit tests (completely forgot about the new split). We'll do that + add an IT in a follow up shortly 👍
SUMMARY
Currently it's possible to create annotations and annotation layers via the API that cause the frontend to crash. For instance, by defining an annotation layer with a
null
name, the edit window crashes with the following error:Also, editing a previously created annotation where the
json_metadata
field had been unset (null
), trying to save the annotation resulted in the following error:This PR updates both the annotation layer and annotation marshmallow schemas to require the minimum amount of defined or non-null values. Note that when leaving out a property on a PUT request, the original object leaves the omitted values untouched, hence a very permissive schema for PUT operations (no required fields). In addition, the frontend logic is updated to no longer crash if an object that was created prior to this PR is edited.
Test cases are added to all relevant permutations of allowed and incorrect POST/PUT payloads. Affected API tests are also updated to correspond to the new minimum requirements.
ADDITIONAL INFORMATION