Repository navigation
fix(core): keep and dispose data-source roots when object-graph tracking throws - #7342
Conversation
|
@codex review |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Root-only discovery contract and implementation src/TUnit.Core/Interfaces/IObjectGraphDiscoverer.cs, src/TUnit.Core/Discovery/ObjectGraphDiscoverer.cs |
The discoverer exposes root-only tracking. It tracks depth-zero objects without traversing their properties. |
Failure fallback and root tracking integration src/TUnit.Core/Tracking/ObjectTracker.cs, src/TUnit.Core/Tracking/TrackableObjectGraphProvider.cs, src/TUnit.Engine/Services/TestFilterService.cs |
After full discovery fails, ObjectTracker removes newly discovered objects, attempts to track roots, and rethrows the original exception. The provider delegates root tracking to the discoverer. Comments describe root disposal for skipped tests. |
Disposal and rollback regression coverage tests/TUnit.UnitTests/ObjectTrackerRollbackTests.cs, tests/TUnit.UnitTests/SharedInstanceLifetimeTests.cs, tests/TUnit.TestProject/Bugs/_7213/ThrowingGetterRootDisposalTests.cs, tests/TUnit.Engine.Tests/Issue7213Tests.cs |
Tests cover fallback rollback, root disposal, throwing property getters, and the resulting failed, passed, and not-executed test results. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested labels: PATCH
Merge Risk: 
Minimal · up to 31a95
-
The reviewed changes have no unresolved merge-blocking concerns in the supplied evidence.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue
#7213requires disposal of root objects when nested discovery throws, for registration failures and skipped tests.ObjectTracker.TrackObjectsnow rolls back discovery additions, tracks roots without property traversal, and preserves the original exception. The implementation retains root reference counts and keeps unreceived row objects disposal-only.ObjectTrackerRollbackTestscovers rollback, root disposal, nested-object removal, and shared-root counts.Issue7213Testsand the_7213test project cover registration failure and skipped-test disposal.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within issue
#7213. Production changes implement root-only fallback tracking, rollback, exception preservation, and the related comment update. The added tests verify the required disposal and reference-count behavior. No unrelated behavior or public API change is demonstrated.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 9 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A root stays tracked when getters fail,
Its nested branches leave the trail.
The original error still returns,
While disposal waits its turn.
A skipped test has roots in view,
And shared counts remain true.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
ReviewThe fix looks correct and well scoped. After a failed discovery, Minor suggestions (none blocking):
Nothing blocks merge from my side. |
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryKeeps root objects tracked for disposal when nested object discovery throws.
Reviews (4) · Last reviewed commit: "test(7213): tag the disposal observer as..." · Reviewed by Greptile |
…ing throws (#7213) When a nested property getter throws while tracking a test's object graph, ObjectTracker rolled back everything discovery added, so the test's root argument objects were neither counted nor tracked and nothing disposed them. After rollback, add only the roots (class and method arguments, direct injected properties, unreceived row objects) without reading their properties, and count them, so completing the test disposes them. Applies to both tests that fail during registration and skipped tests. Fixes #7213
c485852 to
1244439
Compare
Review: PR 7342 (root disposal after a failed discovery)I read the diff and the surrounding Two suggestions:
Minor: The tests cover both the unit-level behaviour (shared root, nested object dropped) and the engine-level cases (failed registration and skipped). The observer test, which uses Overall this looks good, with suggestion 1 worth taking before merge. |
|
Review dispositions for 5329979 (replies to both Claude reviews):
Validation (net10.0): |
|
@codex review |
ReviewThe PR fixes a real leak. The rollback from #7191 dropped the test's root objects along with the nested ones, so nothing ever disposed them. Re-adding only the roots and counting them is a sound, minimal fix. What I checked
Minor suggestions (non-blocking)
LGTM. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Dispositions for the review of 5329979 (both suggestions are non-blocking, so this head stays unchanged):
Claude and Codex both approve this head with no blocking findings, so I'm marking the PR ready. |
ReviewThe change looks correct and well scoped. It fixes the leak in #7213 without breaking the #7191 rollback guarantee. What I checked
Minor suggestions (non-blocking)
No blocking issues. Nice work. |
DependsOn pulls FailsDuringRegistration into any filtered run containing the observer, so tagging it Pass made the EngineTest=Pass run fail in CI. Follow the _6554 and _7123 pattern.
|
CI on 5329979 failed in Dispositions for the non-blocking suggestions in the Claude review of 5329979:
|
ReviewThe fix looks correct and well scoped. I reviewed the diff only and didn't run the tests.
Minor, non-blocking: No blocking issues. LGTM. |
Summary
When a nested property getter throws while
ObjectTracker.TrackObjectsdiscovers a test's object graph, the rollback added in #7191 removed everything discovery had added, including the test's root argument objects. Those roots were never counted, so neither test completion nor the session-end sweep disposed them.IObjectGraphDiscoverer.TrackRootObjects(internal) adds only the test's roots at depth 0: class and method arguments, direct injected property values, and unreceived data-row objects. It does not read any property of them. Unreceived row objects it adds are marked disposal-only, as in normal discovery (First class-data fetch per class row creates an untracked instance that is never disposed (SharedType.None) #7157).ObjectTracker.TrackObjectsstill rolls back what the failed discovery added, then tracks and counts the roots. Nested objects stay dropped, and shared roots get one reference for this test, which completing the test releases. The rollback guarantee from fix(engine): dispose data-source objects of skipped tests and rows #7191 still holds: the test releases only references it took.TestCoordinator'sfinally. A skipped test's roots are now disposed too. I updated the comment inTestFilterServiceto match.Tests
ObjectTrackerRollbackTests.Failed_Discovery_Still_Tracks_And_Disposes_Root_Objects: the root is disposed, the nested object is dropped, and a shared root survives until its other holder releases it.Bugs/_7213plusIssue7213Tests: aClassDataSourceroot whoseIAsyncInitializergetter throws is disposed, both for a test that fails during registration and for a skipped test. The observer test fails without the fix and passes with it.Local validation (net10.0):
TUnit.UnitTests: all 669 tests run, 665 passed and 4 skipped.TUnit.Engine.TestsIssue7213TestsandIssue7156Tests, reflection mode: pass. The AOT engine mode runs only in CI.TUnit.TestProjectwith--treenode-filter "/*/TUnit.TestProject.Bugs._7213/*/*"in source-generated mode: the observer passes, and the registration failure is expected.No public API change: the interface is internal.
Closes #7213
Summary by CodeRabbit