THRIFT-2462: Add netstd recursion-depth round-trip regression test#3563
Open
Jens-G wants to merge 1 commit into
Open
THRIFT-2462: Add netstd recursion-depth round-trip regression test#3563Jens-G wants to merge 1 commit into
Jens-G wants to merge 1 commit into
Conversation
a01f3a4 to
be60e46
Compare
Client: netstd Recursion depth is already enforced on the generated read/write path: the netstd code generator emits IncrementRecursionDepth/DecrementRecursionDepth around the body of every generated WriteAsync/ReadAsync. This adds a round-trip regression test (Binary/Compact/JSON) over nested structs from Recursive.thrift to confirm the limit keeps being enforced, and wires Recursive.thrift into the net10 compile-test project so the generated types are available. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
be60e46 to
cf07bab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation of the recursion-depth handling for netstd showed that the limit is already enforced on the real (generated-code) read/write path: the netstd code generator emits
IncrementRecursionDepth()/DecrementRecursionDepth()around the body of every generatedWriteAsync/ReadAsync(seecompiler/cpp/src/thrift/generate/t_netstd_generator.cc). Nested structs — both known fields (generated code) and unknown fields (TProtocolUtil.SkipAsync) — are therefore already bounded byTConfiguration.RecursionLimit(default 64).An earlier revision of this PR additionally called
IncrementRecursionDepth/DecrementRecursionDepthinside the protocols'WriteStructBegin/EndandReadStructBegin/End. Because the generated code already does this, that counted every struct twice, halving the effective limit and rejecting valid payloads at roughlylimit/2. That change has been dropped — the three protocol files are now unchanged from master.What remains is a round-trip regression test that exercises the limit through the generated
WriteAsync/ReadAsyncpath (not the protocol*StructBegin/Endmethods in isolation), modeled on the Delphi test added in 1ffdcf2.Changes
lib/netstd/Tests/Thrift.Tests/Protocols/TProtocolRecursionDepthTests.cs— new round-trip test over the mutually recursiveCoRec/CoRec2chain and the wideRecTreefromtest/Recursive.thrift, for Binary / Compact / JSON:TProtocolException(DEPTH_LIMIT),DecrementRecursionDepth,Thrift.Compile.net10.csproj— generatetest/Recursive.thriftso the recursive types are available to the test assembly.No production code changes.
Test plan
dotnet test(Thrift.Tests): 18 / 18 pass.Co-authored with Claude Opus 4.8.