Accept an omitted value as null on PUT /v1/members/{id}/fields - #274
Open
SiteRelEnby wants to merge 1 commit into
Open
Accept an omitted value as null on PUT /v1/members/{id}/fields#274SiteRelEnby wants to merge 1 commit into
SiteRelEnby wants to merge 1 commit into
Conversation
Clearing a custom field is expressed as value: null, but value: Any with
no default is a required field in Pydantic v2, so an entry that omits
value entirely was rejected and the whole request 422'd. Several client
serialisers drop null object fields by default - Moshi on Android is how
this surfaced: emptying a field serialised to [{"field_id": ...}] and
clearing silently failed.
Absence has no other meaning on this endpoint: the handler upserts every
entry it is given and there is no omit-to-leave-alone mode, so omitted
can only sensibly mean the same as an explicit null. Defaulting the
field accepts it as exactly that. Clients already sending the null are
unchanged. Regression test pins both clearing spellings as equivalent.
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.
Fixes clearing a member custom field from clients whose JSON serialiser omits null object fields (Moshi on Android is how this surfaced: emptying a field serialised to
[{"field_id": ...}]and the whole request 422'd - see sheaf-project/android#68 for the client-side half).value: Anywith no default is a required field in Pydantic v2, so an entry that omittedvaluewas rejected outright. It now defaults toNone, making an omitted value clear the field exactly like an explicit null. This is safe because absence has no other meaning on this endpoint: the handler upserts every entry it is given, there is no omit-to-leave-alone mode, andNonealready flows correctly through type validation, the text cap, and encrypted storage. Clients that send the explicit null are unchanged.Checked for siblings: the only other no-default
Anyin the schemas is a response model, and the PATCH endpoints that do distinguish omitted from null (fields_setsemantics) are deliberate and untouched.Regression test pins both clearing spellings as equivalent. Full behavioural config green. The Android explicit-null fix remains necessary independently - self-hosted servers upgrade on their own schedule, so this is defence in depth for other clients, not a replacement.