compiler-segfault opened a new pull request, #3656:
URL: https://github.com/apache/iceberg-rust/pull/3656
## Which issue does this PR close?
- Closes #3627.
## What changes are included in this PR?
`NestedField` is serialized through `SerdeNestedField`, and the
`From<NestedField>` conversion used `expect` when a default value could not be
converted to JSON. A field whose default does not fit its type therefore
panicked inside `serde_json::to_string`, which is reachable from
`with_initial_default` / `with_write_default`:
```rust
let field = NestedField::new(1, "f", Type::Primitive(PrimitiveType::Float),
false)
.with_initial_default(Literal::string("1e39"));
serde_json::to_string(&field); // panics
```
The conversion is now fallible (`TryFrom<NestedField> for
SerdeNestedField`), and `NestedField`'s hand-written `Serialize` passes that
error through `serde::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::tests` cover the initial and the write
default: both panic before the change and assert the serialization error
afterwards. `cargo test -p iceberg --lib` passes (2141 passed, 1 ignored), and
`cargo clippy -p iceberg --all-targets -- -D warnings` and `cargo fmt` are
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::custom` is the right surface for it, or
whether `Serialize` should stay infallible and the type/validity check should
move into `with_initial_default` / `with_write_default` instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]