Skip to content

Commit 46a2ef2

Browse files
hbarthelsclaude
andauthored
Make int32 config parsing strict and loud (#266)
Previously `_extract_value_int32` silently returned the field default when a config value was present but not an `int32_value` (e.g. a bare `2` instead of `2i32`). That silent fallback masked malformed input. Now the helper errors loudly (`ParseError`) when a config value is present with the wrong type, while still keeping the `i32` suffix requirement and returning the default only when the field is genuinely absent. Edited `meta/src/meta/grammar.y` and regenerated the Python, Julia, and Go parsers. Added regression tests in the Julia and Python SDKs covering: a properly-typed `2i32` parses, a bare `2` raises `ParseError`, and omitting the field yields the default (1). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 671608d commit 46a2ef2

6 files changed

Lines changed: 343 additions & 274 deletions

File tree

meta/src/meta/grammar.y

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,9 +1456,11 @@ export_iceberg_config
14561456

14571457

14581458
def _extract_value_int32(value: Optional[logic.Value], default: int) -> Int32:
1459-
if value is not None and builtin.has_proto_field(builtin.unwrap_option(value), 'int32_value'):
1459+
if value is None:
1460+
return builtin.int64_to_int32(default)
1461+
if builtin.has_proto_field(builtin.unwrap_option(value), 'int32_value'):
14601462
return builtin.unwrap_option(value).int32_value
1461-
return builtin.int64_to_int32(default)
1463+
builtin.error("expected an int32 value (e.g. `1i32`) for this config field")
14621464

14631465

14641466
def _extract_value_int64(value: Optional[logic.Value], default: int) -> int:

0 commit comments

Comments
 (0)