Repository navigation
fix(spec): report an error instead of panicking when a field default cannot be serialized - #3656
Open
compiler-segfault wants to merge 2 commits into
Open
compiler-segfault wants to merge 2 commits into
compiler-segfault wants to merge 2 commits into
Conversation
…cannot be serialized SerdeNestedField was built from NestedField with From and an expect, so a default literal that does not fit the field type aborted the process inside serde_json::to_string. Make the conversion fallible and report it through serde::ser::Error::custom from a hand-written Serialize impl. Fixes apache#3627.
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?
What changes are included in this PR?
NestedFieldis serialized throughSerdeNestedField, and theFrom<NestedField>conversion usedexpectwhen a default value could not be converted to JSON. A field whose default does not fit its type therefore panicked insideserde_json::to_string, which is reachable fromwith_initial_default/with_write_default:The conversion is now fallible (
TryFrom<NestedField> for SerdeNestedField), andNestedField's hand-writtenSerializepasses that error throughserde::ser::Error::custom, so serialization fails instead of aborting the process. Nothing else about the JSON shape changes.Are these changes tested?
Two tests in
spec::datatypes::testscover the initial and the write default: both panic before the change and assert the serialization error afterwards.cargo test -p iceberg --libpasses (2141 passed, 1 ignored), andcargo clippy -p iceberg --all-targets -- -D warningsandcargo fmtare clean.AI Disclosure
The change and this description were prepared with an AI coding agent (DeepSeek Harness,
deepseek-flash). The diff and the test output were reviewed before submitting.Uncertainty worth a reviewer's attention: whether reporting the conversion failure through
serde::ser::Error::customis the right surface for it, or whetherSerializeshould stay infallible and the type/validity check should move intowith_initial_default/with_write_defaultinstead.