Repository navigation
Conversation
These columns are NOT NULL, so an explicit null in PATCH
/profiles/{id} failed on commit with a 500. It is now a 422
VALIDATION_ERROR and the profile is left unchanged.
Fixes fireform-core#755
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PATCH /api/v1/profiles/{profile_id}returned 500 when the body setname,professionorroletonull.ProfileUpdatedeclares themstr | None = Noneso they can be left out, but an explicitnullalso passed validation, was copied onto the row, and the commit failed on the NOT NULL constraint (sqlite3.IntegrityError: NOT NULL constraint failed: profiles.name).This adds a
field_validatoronProfileUpdatethat rejectsNonefor those three fields, so the request now gets the usual 422VALIDATION_ERRORnaming the field, and the profile is left unchanged.{"name": null}(orprofession/role)IntegrityErrorVALIDATION_ERROR, fieldname{"role": "Battalion Chief"}{"description": null, "custom_fields": null}Omitted fields aren't validated, so partial updates work as before. The Settings page always sends strings, so no frontend change is needed.
Fixes #755
Type of change
How Has This Been Tested?
tests/test_v1_profiles.py:test_profile_patch_rejects_null_required_field(name,profession,role): 422 naming the field, and a follow-up GET shows the value unchanged. All three fail ondevelopmentwith theIntegrityErrorabove.test_profile_patch_allows_null_optional_fields:description/custom_fieldscan still be cleared, other fields untouched.python -m pytest tests/→ 417 passedruff check app/→ all checks passedTest Configuration:
Checklist: