fix: depth decrementing was passed by reference and all same depth ch…#2740
fix: depth decrementing was passed by reference and all same depth ch…#2740
Conversation
…ecks were decreasing the number. passing copy of request when nested
📝 WalkthroughWalkthroughAdjusts check depth handling and request mutation: DirectInvoker.Check now copies the request and decrements depth on the copy; depth validation treats zero as valid (only negative depths rejected); adds tests covering 3-level depth behavior (allowed/denied cases). Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2740 +/- ##
==========================================
- Coverage 82.63% 82.61% -0.01%
==========================================
Files 74 74
Lines 8125 8125
==========================================
- Hits 6713 6712 -1
- Misses 893 894 +1
Partials 519 519 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| }, | ||
| ) | ||
|
|
||
| Expect(err).ShouldNot(HaveOccurred()) |
There was a problem hiding this comment.
So we're using the "strict" mocking here? Where we don't just stub things, but expect things to be called in a certain order, etc. ?
|
|
||
| atomic.AddInt32(&request.GetMetadata().Depth, -1) | ||
| // Create a copy of the request to safely decrement depth without mutating the original. | ||
| nextRequest := request.CloneVT() |
There was a problem hiding this comment.
what happens if we do mutate the original?
There was a problem hiding this comment.
the depth is decremented on every deeper call. previously if a lower level had multiple leaves, it ended up decreasing the depth multiple times, when it should have only decreased once
| } | ||
| ` | ||
|
|
||
| Context("Depth Check Sample: Check", func() { |
There was a problem hiding this comment.
Did these 2 tests fail, once written, before the fixes were made in invoke.go and utils.go?
There was a problem hiding this comment.
before the changes, the case that should pass was failing. i added these tests because this scenario specifically requires a depth of 3. i included both failing and passing cases to verify the behavior.
…ecks were decreasing the number. passing copy of request when nested
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.