-
Notifications
You must be signed in to change notification settings - Fork 394
Update KeyUploadServlet
to handle case where client sends device_keys: null
#19023
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
Conversation
…eys: null` Fixes an edge case where a client could set `device_keys`, but set it to `null`.
Confirmed that this currently fails on `develop`.
A regression unit test was added as per @devonh's suggestion. |
👍 to a quick fix to get the release out today, but there is no question that this is client-side misbehaviour which Synapse should reject, otherwise all other server implementations end up having to allow Please could you plan to revert this change in due course (say, three months)? I'd recommend adding a warning in the meantime, so that we can get an idea of when it will be safe to revert. |
For links: this was followup to #17097 |
@richvdh Good point. I think we actually need a way in Pydantic to differentiate between a field not being set, and said field being set to # Reject explicit `null` for any field that opts in with Field(..., forbid_null=True)
@validator('*', pre=True)
def _forbid_explicit_nulls(cls, v, values, field):
if v is None and field.field_info.extra.get('forbid_null', True):
raise ValueError(f"{field.name} cannot be null")
return v to I'll create a proper issue for this soon. |
I'm not entirely following you. I thought that the problem that this PR solved was that a field that was explicitly |
@richvdh Ideally we would return a 4xx error when a client sets a field to The code above supports this by introducing a Right now, any |
Other way around. The field being
|
oh I seeee, the problem with #17097 wasn't the introduction of Pydantic validation, but rather some additional validation that was done outside Pydantic. With you now. |
Fixes an edge case where a client could set
device_keys
, but set it tonull
, as shown in the following traceback:Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.