Make int32 config parsing strict and loud#266
Merged
Conversation
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>
b4b9b64 to
cc763b0
Compare
comnik
approved these changes
Jul 12, 2026
davidwzhao
approved these changes
Jul 12, 2026
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.
Summary
_extract_value_int32previously silently returned the field default when a config value was present but not anint32_value(e.g. a bare2written instead of2i32). That silent fallback masked malformed input — the real bug was the silent failure, not strictness.This changes the helper to error loudly (
ParseError) when a config value is present with the wrong type, while:i32suffix requirement (we do not promote bare ints), andThis is a fresh take on #265 addressing @comnik's review feedback: don't promote — error loudly on the wrong type.
Changes
meta/src/meta/grammar.y: rewrote_extract_value_int32— absent field → default; presentint32_value→ return it; present anything else →builtin.error(...). Emitted as a bare statement (thebuiltin.errortemplate codegens toraise/throw/panic, which is invalid in areturnposition).make force-parsers. The bulk of the generated-file diff is temp-variable (_tNNNN) renumbering; the only logic change is_extract_value_int32. Go builds clean.parser_tests.jl, Pythontest_parser.py)::csv_header_row 2i32parses (header_row == 2); a bare2raisesParseError; omitting the field yields the default (1).No version bump — that goes in its own separate PR.
Testing
789 passed174/174test items,33740assertions passgo test ./test/...andgo build ./...pass🤖 Generated with Claude Code