Skip to content

fix(protobuf_lark): replace bare assert with explicit raise ValueError#180

Open
SoundMatt wants to merge 1 commit into
COVESA:masterfrom
SoundMatt:fix/protobuf-lark-assert-to-raise-valueerror
Open

fix(protobuf_lark): replace bare assert with explicit raise ValueError#180
SoundMatt wants to merge 1 commit into
COVESA:masterfrom
SoundMatt:fix/protobuf-lark-assert-to-raise-valueerror

Conversation

@SoundMatt

Copy link
Copy Markdown

Two assert(len(o.children) == 1) calls in process_enums and process_lark_tree validate the shape of a parsed option node. Bare assert statements are silently disabled when Python is run with the -O flag (optimised mode, e.g. in some production deployments), meaning malformed nodes would pass through silently.

Replace each with an explicit if … raise ValueError(...) so the check is always active and produces a diagnostic message that includes the actual count.

Two bare `assert(len(o.children) == 1)` calls in `process_enums` and
`process_lark_tree` are converted to explicit `if … raise ValueError`
checks.  Bare asserts are silently disabled when Python runs with -O
(optimized mode), making the parser accept malformed option nodes
without any error.  An explicit raise is always active and also
provides a clearer diagnostic message.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant