You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add serializer for AssertRefSnapshotId allowing null json value (#2375)
Closes#2342
# Rationale for this change
The last attempt at fixing this (#2343) did not actually end up
serializing None values to `null`. This was b/c the
`AssertRefSnapshotId` requirement was often a child object of some other
`Request` object, which was actually getting the `model_dump_json()`
call. This meant that the `exclude_none=True` override would remove any
`None`s _before_ any of the `Field`-specific configurations would be
considered (like `exclude=False` or the model's own `model_dump_json`
method).
I then investigated setting some `ConfigDict` settings on the model, but
that also did not have any useful configurations.
I looked into setting `exclude_none=True` at all of the
`model_json_dump()` callsites but there were too many and it would be
easy to forget to set that value every time. The issue is that many
values are _supposed to be absent_ to instruct the REST Catalog about
what the client wants (things like filtering, for instance).
~The solution I ended up with was allowing `snapshot_id` to be a
required `int` with a default value of `-1`, and adding a json-specific
field serializer to write out `null` when dumping to json. This seems to
work~
The solution that worked and allowed for `snapshot_id` to be set to
`None` (as it's done in Ray Data), was to define a `model_serializer`
method and always return the fields. This was based on conversations in
pydantic/pydantic#7326.
## Are these changes tested?
Yes
## Are there any user-facing changes?
Actually allow `snapshot-id` to be null for `assert-ref-snapshot-id`
requirements
---------
Co-authored-by: Kevin Liu <[email protected]>
0 commit comments