Skip to content

Return an error for deeply nested expressions in proto conversion - #11558

Open
Bhup-GitHUB wants to merge 2 commits into
vortex-data:developfrom
Bhup-GitHUB:fix/proto-expr-nesting-depth-11424
Open

Bhup-GitHUB wants to merge 2 commits into
vortex-data:developfrom
Bhup-GitHUB:fix/proto-expr-nesting-depth-11424

Conversation

@Bhup-GitHUB

Copy link
Copy Markdown

Closes #11424

serialize_proto and Expression::from_proto recursed once per nesting level with no bound. A deeply nested expression, for example thousands of folded not or and nodes, overflowed the stack and aborted the process instead of returning an error. Decoding from bytes was only bounded by prost's default recursion limit, which does not apply to a pb::Expr built in memory or to serialization.

Both directions now share one depth check and return the same error past the new public MAX_EXPR_PROTO_DEPTH, which callers that build pb::Expr by hand can check against. The limit is 100 levels, counting the root expression as one, which stays within prost's default decode recursion limit, so any expression Vortex serializes can also be decoded. Tests cover the limit boundary in both directions, the encoded decode path, and a 10,000-deep expression that now errors instead of overflowing.

Before:

before-11424.png

After:

after-11424.png

This PR was prepared with AI assistance; I reviewed the change and ran the tests.

serialize_proto and from_proto recursed once per nesting level with no
limit, so a deeply nested expression overflowed the stack and aborted the
process. Both directions now return an error past MAX_EXPR_PROTO_DEPTH
(100), which stays within prost's default decode recursion limit.

Signed-off-by: Bhupesh Kumar <145711585+Bhup-GitHUB@users.noreply.github.com>
Check the limit boundary for serialize_proto, from_proto and the encoded
decode path, and that a 10,000-deep expression errors instead of
overflowing the stack.

Signed-off-by: Bhupesh Kumar <145711585+Bhup-GitHUB@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

Bound expression nesting depth in serialize_proto and from_proto

1 participant