shtripat opened a new pull request, #758:
URL: https://github.com/apache/iceberg-go/pull/758

   This change replaces panics with errors in schema visitors and add JSON 
field validation
   
   This PR fixes two classes of bug that could cause runtime panics in the 
schema layer:
   
   1. **`panic()` used as an error-signalling mechanism** in schema visitor 
implementations (`indexByName`, `pruneColVisitor`, `sanitizeColumnNameVisitor`, 
`validAvroName`, `sanitizeName`). While `Visit`'s `defer recover()` masked 
these as errors at the surface, relying on panic-as-control-flow is 
non-idiomatic, loses stack context, and is fragile.
   
   2. **Silent JSON key mismatches producing zero-value fields**. Go's 
`json.Unmarshal` ignores unknown keys, so a payload using `"field_id"` instead 
of `"id"` (or `"field_name"` instead of `"name"`) silently produces `ID=0` / 
`Name=""`. These zero values then propagate to the visitor code, triggering the 
panics described above.
   
   The `SchemaVisitor[T]` generic interface returns only `T` per method, so 
error returns cannot be added without a breaking API change. Instead, **error 
accumulation** is used: visitors store a first-error in an `err` field, visitor 
methods short-circuit with `if x.err != nil { return <zero> }` after an error 
is set, and the calling function (`PruneColumns`, `IndexByName`, etc.) checks 
the accumulated error after `Visit` returns.
   
   Fixes: https://github.com/apache/iceberg-go/issues/757


-- 
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]

Reply via email to