Jens-G opened a new pull request, #3411:
URL: https://github.com/apache/thrift/pull/3411

   ## Summary
   
   `TProtocolBase.skip()` in Python had no recursion depth limit. When 
deserializing an unknown field, generated code calls `skip()`, which 
recursively calls itself for each nested container or struct element. C++, Go, 
and Node.js all cap this recursion at 64 levels and raise a protocol exception 
when the limit is exceeded.
   
   This change brings Python into parity:
   
   - **`lib/py/src/protocol/TProtocol.py`**: `skip()` gains an optional 
`max_depth` parameter (default 64). At the start of each call, if `max_depth <= 
0` a `TProtocolException(DEPTH_LIMIT)` is raised. All recursive calls pass 
`max_depth - 1`.
   
   Tests added in `lib/py/test/thrift_TBinaryProtocol.py`:
   - `test_skip_rejects_deeply_nested_struct`: a payload with 64 levels of 
nesting raises `DEPTH_LIMIT`.
   - `test_skip_accepts_struct_within_depth_limit`: a payload with 63 levels 
succeeds.
   
   ## Test plan
   
   - [ ] `python3 lib/py/test/thrift_TBinaryProtocol.py -v` — two new skip 
depth tests pass
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to