fix: store a list of models that admits a None - #1977
Open
shcheklein wants to merge 1 commit into
Open
Conversation
This was referenced Sep 2, 2026
Deploying datachain with
|
| Latest commit: |
b1b6e6e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5a52a799.datachain-2g6.pages.dev |
| Branch Preview URL: | https://fix-optional-model-array-ite.datachain-2g6.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
is_chain_type accepts list[Child | None] and list[Child] writes, but map(output=...) raised "Cannot recognize type Child" while building the schema: the union arm hid the model from the check that maps a model element to JSON. Ask that check what the arm holds as well. Only a plain Model | None is admitted. An Annotated[Model, ...] | None would be stored and then handed back as plain dicts, because rebuilding a nested model does not look through Annotated, and a root model dumps to whatever it wraps where the reader rebuilds one only from a mapping -- list[RootModel[int]] reads back as bare ints on main already. Both keep raising rather than storing something that reads wrong. Every slot of a fixed tuple is checked, since they share the one column: a slot that cannot be read back as a model still refuses the annotation. Nothing that already wrote is affected -- these raised before, so there is no stored form to stay compatible with. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
shcheklein
force-pushed
the
fix/optional-model-array-items
branch
from
September 2, 2026 17:32
1972716 to
b1b6e6e
Compare
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.
Stacked on #1976.
is_chain_typeacceptslist[Child | None], andlist[Child]writes, butbuilding the schema raised:
The check that maps a model element to JSON looked at the annotation as written,
and the union arm was all that hid the model. It asks what the arm holds now.
With #1975's
flattenfix already in place, all three orders round-trip:What stays refused, deliberately
Only a plain
Model | Noneis admitted. Two shapes are stored wrong rather thannot at all, so they keep raising:
list[Annotated[Child, "meta"] | None]Annotated, so it comes back as[None, {'x': 1}]list[RootModel[int] | None][None, 1]list[RootModel[int]]already reads back as bare ints onmain— that ispre-existing and left alone; what this must not do is admit a spelling
mainrefuses and then store it wrong.
Every slot of a fixed tuple is checked too, since they share the one column:
tuple[A | None, Annotated[B, "meta"] | None]is refused on the strength of itssecond slot, while
tuple[A | None, B | None], whose slots both read back asmodels, is allowed. A whole-model read hides this class of bug, because Pydantic
revalidates the dict — only a leaf read shows it.
Compatibility
Nothing that already wrote is affected: every annotation here raised before, so
there is no stored form to stay compatible with. Storage is unchanged across the
fourteen annotations checked in #1975, and the declared type changes only for
list[Model | None], which had none.Stack
Noneanywhere in an arrayNone