The GitHub Actions job "Pull Request Labeler" on 
iceberg-go.git/input-validation-with-error-no-panic has succeeded.
Run started by GitHub user shtripat (triggered by shtripat).

Head commit for run:
cbe6f7eb40fd2a3df58bf76a7a226ab96671381b / Shubhendu Ram Tripathi 
<[email protected]>
fix: replace panics with proper error returns

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.

Signed-off-by: Shubhendu Ram Tripathi <[email protected]>

Report URL: https://github.com/apache/iceberg-go/actions/runs/22409532292

With regards,
GitHub Actions via GitBox

Reply via email to