Repository navigation
fix(dashpay): don't check a pending invitation twice after a replaced one - #1325
llbartekll wants to merge 2 commits into
Conversation
… one A check asked for while another check of the same invitation was running could start after that check had already answered: `validateIfPossible` saw no cached verdict and spawned the task, but `runValidation` never looked at the verdict again once the task actually ran. With a stale check finishing for a hidden-and-replaced invitation, the replacement was then validated twice. `runValidation` now returns a fresh verdict for the shown invitation instead of starting a second check, the same test `validateIfPossible` applies before spawning. Fixes the flaky PendingInvitationViewModelTests.testACheckFinishingForAReplacedInvitationIsDiscarded (11 failures in 2000 iterations before, 0 in 2000 after). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 56 minutes. View limit details
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. |
|
🕓 Review not started yet because the new head is waiting for the 30-minute push debounce.
Commit 58ba061. Normal review starts when eligible; priority review starts as soon as a slot is available. |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Verified the eight-line change at head 67b1099 against the base implementation, validation callers, scoped invitation model, and existing tests. The added cache check closes the duplicate-validation scheduling window while preserving explicit invalidation and the existing freshness policy; no in-scope defects were found. Current CI reports successful simulator tests, target-membership validation, and accessibility checks, with only the automated review pending; validation here was static, with no local builds or tests run.
Review provenance
Source: reviewer 1: glm-5.3-flash (agent: phase1-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)
- Triage:
lowbygpt-6.1-sol(effort low) — The diff adds a small, localized freshness guard that reuses an existing validation verdict without changing broader invitation behavior or a critical surface. - Phase 1 reviewers:
glm-5.3-flash— general (completed, effort high); agentphase1-reviewer - Phase 1 model:
glm-5.3-flash— zai quota: 5h 99% left, weekly 99% left; passed overgemini-3.8-flash-high(antigravity quota lookup failed) - Fresh verifier:
gpt-6.1-sol— final-verifier; agentsol-verifier - Phase 2 reviewers:
gpt-6.1-sol— general (completed, effort medium); agentphase2-reviewer,gpt-6.1-sol— security-auditor (completed, effort medium); agentphase2-reviewer
|
Superseded by #1339, which landed the same guard in |
Issue being fixed or feature implemented
PendingInvitationViewModelTests.testACheckFinishingForAReplacedInvitationIsDiscardedis flaky: it expectsvalidator.calls == [linkA, linkB]and intermittently sees[linkA, linkB, linkB]. It failed once on CI ("DashWalletTests on simulator", on an unrelated PR) and reproduces locally at roughly 1 in 200 iterations.The cause is in
PendingInvitationViewModel, not in the test: the view model can validate the same pending invitation twice.validateIfPossiblechecks the cached verdict and then spawns a task;runValidationnever looks at the verdict again when that task actually runs. The failing order, taken from an instrumented run (everything on the main actor):receive(linkB)spawns a task that waits for the stale check A.validateIfPossiblespawns a third task.validationTask.The test's scripted validator answers instantly, which is what makes the window wide enough to hit. In production the same hole needs B's network check to finish before the third task starts, so it is rare; when it happens the cost is a redundant network check and the card showing "verifying" again while it runs.
What was done?
Before starting a check,
runValidationnow returns a freshlastVerdictfor the shown invitation instead of checking again. It is the same freshness testvalidateIfPossibleapplies before spawning the task, and the same onecreateuses for its cached path.Callers that want a new check (
recheck,createpast the cache window or for an ineligible wallet, the end of a registration, a status change) clearlastVerdictfirst, so they are unaffected: any verdict present when the task runs is newer than their request.One file, 8 lines. No test changes.
How Has This Been Tested?
Scheme
dashwallet-dashpay, Debug,ARCHS=arm64 ONLY_ACTIVE_ARCH=YES, iOS 26.5 simulator, platform at.platform-ref.develop, the one test × 2000 iterationsPendingInvitationViewModelTests× 200 iterations (3800 tests)No dedicated regression test is added: the bad order depends on task scheduling and I found no deterministic way to force it, so the existing test under iteration is the guard. Not exercised in the running app.
Breaking Changes
None.
Checklist:
no significant decisionFor repository code-owners and collaborators only
🤖 Generated with Claude Code