What version of protobuf and what language are you using?*
protobuf 7.34.1 (Python runtime), also reproduced on main
Language: Python
What supported operating system are you using?
Linux (Ubuntu 24.04)
What supported runtime / compiler version are you using?
Python 3.12
What did you do?
json_format.Parse() with max_recursion_depth set does not limit recursion for google.protobuf.Struct, Value, or ListValue messages.
ConvertMessage() tracks depth correctly for regular messages, but Struct/Value/ListValue dispatch through _WKTJSONMETHODS into _ConvertValueMessage / _ConvertStructMessage / _ConvertListOrTupleValueMessage. These three methods call each other directly without re-entering ConvertMessage(), so recursion_depth is never incremented past the initial entry.
from google.protobuf import json_format, struct_pb2
import json
nested = {"v": "leaf"}
for _ in range(200):
nested = {"k": nested}
msg = struct_pb2.Struct()
json_format.Parse(json.dumps(nested), msg, max_recursion_depth=5)
# Expected: ParseError ("Message too deep")
# Actual: parses successfully, depth limit ignored
This is the same pattern that was fixed for Any messages (where nested Any parsing was routed back through ConvertMessage()). The Struct/Value/ListValue cycle was not updated at that time.
What did you expect to see
ParseError with message "Message too deep" when nesting exceeds max_recursion_depth.
What did you see instead?
Message parses successfully with no error. The depth limit is completely ignored for Struct/Value/ListValue nesting.
What version of protobuf and what language are you using?*
protobuf 7.34.1 (Python runtime), also reproduced on main
Language: Python
What supported operating system are you using?
Linux (Ubuntu 24.04)
What supported runtime / compiler version are you using?
Python 3.12
What did you do?
json_format.Parse()withmax_recursion_depthset does not limit recursion forgoogle.protobuf.Struct,Value, orListValuemessages.ConvertMessage()tracks depth correctly for regular messages, but Struct/Value/ListValue dispatch through_WKTJSONMETHODSinto_ConvertValueMessage/_ConvertStructMessage/_ConvertListOrTupleValueMessage. These three methods call each other directly without re-enteringConvertMessage(), sorecursion_depthis never incremented past the initial entry.This is the same pattern that was fixed for
Anymessages (where nested Any parsing was routed back throughConvertMessage()). The Struct/Value/ListValue cycle was not updated at that time.What did you expect to see
ParseErrorwith message "Message too deep" when nesting exceedsmax_recursion_depth.What did you see instead?
Message parses successfully with no error. The depth limit is completely ignored for Struct/Value/ListValue nesting.