Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ruby] More flexible ENCODE_MAX_NESTING #1493

Closed
marcinwyszynski opened this issue May 5, 2016 · 1 comment · Fixed by #9218
Closed

[ruby] More flexible ENCODE_MAX_NESTING #1493

marcinwyszynski opened this issue May 5, 2016 · 1 comment · Fixed by #9218

Comments

@marcinwyszynski
Copy link
Contributor

At codebeat we have a legitimate use case for deeply nested protocol buffers - we use these to represent ASTs. We know for sure there are no cycles in our data structures so we wouldn't like to be limited by an arbitrary number we can't change. And we can't since it's set in a header file so without forking a repo and manually changing it there is not much we can do. We would like to kindly request that this constant is turned into a Ruby constant that can be modified by the caller.

@lfittl
Copy link
Contributor

lfittl commented Mar 30, 2021

For anyone finding this (like I have) - this is still an issue after the recent ubp refactoring in the Ruby library.

The _ubp_decode method now allows passing in options (see here), which theoretically would let one increase the limit from the default of 64 levels deep, but this is not yet available in the Ruby level API, since the relevant function calls ubp_decode (not _ubp_decode with the leading underscore, that allows the depth to be passed in as an option):

if (!upb_decode(RSTRING_PTR(data), RSTRING_LEN(data), (upb_msg*)msg->msg,
upb_msgdef_layout(msg->msgdef),
Arena_get(msg->arena))) {
rb_raise(cParseError, "Error occurred during parsing");
}

lfittl added a commit to lfittl/protobuf that referenced this issue Nov 13, 2021
This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to parse complex nested protobuf messages that otherwise error out
with "Error occurred during parsing".

Fixes protocolbuffers#1493
lfittl added a commit to lfittl/protobuf that referenced this issue Nov 13, 2021
This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to parse complex nested protobuf messages that otherwise error out
with "Error occurred during parsing".

Fixes protocolbuffers#1493
lfittl added a commit to lfittl/protobuf that referenced this issue Nov 14, 2021
This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to encode or decode complex nested protobuf messages that otherwise
error out with a RuntimeError or "Error occurred during parsing".

Fixes protocolbuffers#1493
lfittl added a commit to lfittl/protobuf that referenced this issue Dec 9, 2021
This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to encode or decode complex nested protobuf messages that otherwise
error out with a RuntimeError or "Error occurred during parsing".

Fixes protocolbuffers#1493
acozzette added a commit that referenced this issue Feb 9, 2022
* Message.decode/encode: Add max_recursion_depth option

This allows increasing the recursing depth from the default of 64, by
setting the "max_recursion_depth" to the desired integer value. This is
useful to encode or decode complex nested protobuf messages that otherwise
error out with a RuntimeError or "Error occurred during parsing".

Fixes #1493

* Address review comments

Co-authored-by: Adam Cozzette <acozzette@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants