fix(variant): avoid panic on variant_get for non-nullable field - #11356
Open
neilconway wants to merge 1 commit into
Open
neilconway wants to merge 1 commit into
neilconway wants to merge 1 commit into
Conversation
…ist items in `variant_get` `variant_get` built List and ListView results with `GenericListArray::new` and `GenericListViewArray::new`, which panic if the array would be invalid. So asking for a list type with a non-nullable item field panicked, rather than returning an error, whenever an item in the result was null: either a null element in the variant list, or an element that a safe cast turned into null because it did not fit the item type. Use `try_new`, as the FixedSizeList and struct paths already do.
Jefffrey
approved these changes
Oct 3, 2026
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.
Which issue does this PR close?
Rationale for this change
variant_getbuiltListandListViewresults usingGenericListArray::newandGenericListViewArray::new, which panic if the array would be invalid. Given a list type with a non-nullable field, asking for a result with a null value in such a field would panic instead of returning an error.What changes are included in this PR?
try_newinstead ofnew, matching the existing FSL and struct pathsAre these changes tested?
Yes; existing test pass, new test added.
Are there any significant user-facing changes?
No.
AI usage
Developed with Claude Code (Opus 5.5). I have reviewed and understand the resulting code.