Repository navigation
test(backend): cover the 503 claim path and shared-task provenance - #18719
Conversation
…test The six tests added by #17830 have never passed. They were written against an API that does not exist, so every one of them errored before reaching its assertion: TypeError: accept_shared_action_items() got an unexpected keyword argument 'payload' Three separate mismatches, all in the tests: test called handler actually uses -------------------------------------- ----------------------------------- accept_shared_action_items(payload=...) parameter is named `request` redis_db.verify_task_share_token redis_db.get_task_share action_items_db.get_action_items_by_ids action_items_db.get_action_item The fixture also passed task_ids and sender_id to AcceptSharedTasksRequest, which only declares token, and the expected return shape ({'status', 'accepted_count', 'created_items'}) did not match the handler's {'created', 'count'}. The undo assertion expected undo_accept_task_share(token, task_ids); the real signature is (token, uid). The handler is correct -- it implements exactly what #17830 describes, routing deleted to 404 and locked to 402 -- so the tests are rewritten against it rather than the other way round. Every scenario #17830 set out to cover is kept, plus two the original missed: an expired share token (404) and a Redis claim that returns None rather than False (503). Verified: 8 passed, was 6 failed. Mutation-checked in both directions -- the suite fails when the 402 becomes a 403, when the deleted-items guard is short-circuited, and when the token rollback is removed. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Verified end to end before reading the description — the premise holds:
One overlap to be aware of: main has since landed What survives a rebase is exactly the delta worth keeping: the unavailable-claim → 503 test, the Flagging the keep-increment-vs-close call for a maintainer, since the overlapping commit landed on main shortly after this PR opened. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address the required patch.object usage and strengthen UID and per-item provenance assertions.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Reworks shared action-item tests to match the current handler API and expands edge-case coverage.
Changes:
- Corrects request, Redis, database, response, and rollback expectations.
- Adds expired-token and unavailable-claim coverage.
- Verifies provenance, wake notifications, and rollback behavior.
| File | Summary |
|---|---|
backend/tests/unit/test_shared_action_items.py |
Updates and expands shared action-item handler tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ms-test-wiring # Conflicts: # backend/tests/unit/test_shared_action_items.py
|
Taking the keep-the-increment path — retitled and reduced to +29 lines, no deletions on You were right that
I dropped the Mutation-checked each new assertion rather than trusting that it runs:
8 passed on the merged head; |
…the first The success test inspected only create_action_item.call_args_list[0], so a regression in the second copy's shared_from would have passed while the comment claimed each copy was covered. Now every call is checked: recipient uid, sender_uid, the copy's own original_task_id, the share token, and completed, plus the per-copy upsert_action_item_vector arguments. Mutation-checked the gap that motivated this: corrupting original_task_id on the last copy only, and passing a wrong id to upsert_action_item_vector, each turn the suite red. Neither was caught before. Co-Authored-By: Claude Opus 5 <[email protected]>
kodjima33
left a comment
There was a problem hiding this comment.
Trusted backend contributor; test-only coverage PR (no prod code change), CI green. Approve-only per confidence gate (not a bug fix).
|
Follow-up verification on the reduced head
Ran the file in a worktree: 8 passed in 2.00s. I also reproduced the mutation table independently — flipping the handler's 503 to 409 and corrupting Dropping the Cleanly mergeable against main, checks green. Thanks for the careful reduction — this is exactly the delta worth keeping, and the mutation table matched my results line for line. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
…ms-test-wiring # Conflicts: # backend/tests/unit/test_shared_action_items.py
|
Conflict resolved on
The intent is unchanged: every copy — not just the first — goes to the recipient in that one batch, carries Mutation-checked against the new batch handler rather than trusting that the tests run:
Handler restored byte-identical. |
|
Verified on the current head 5291706 after the main merge — the rework against the batch write is exactly right, and this remains a clean, test-only increment (+37/−0, one file).
Note for merge: the earlier approval was on 45ab5f8, two heads back; since this head only re-resolves the main merge and reworks test assertions (no production changes), re-approval should be trivial. Thanks for keeping the increment intact through two rounds of main moving underneath it. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Test-coverage-only addition (no production code changed) on top of the real fix already merged to main as cf24718; covers two previously-untested branches (503 path, shared_from provenance). Approve-only — not itself a bug fix, so doesn't qualify for auto-merge, but low-risk and CI green.
kodjima33
left a comment
There was a problem hiding this comment.
Test-only addition covering the 503 path and shared-task provenance; approve-only per confidence gate, CI green.
kodjima33
left a comment
There was a problem hiding this comment.
Test-only addition (covers 503 claim path + provenance not covered by the sibling merge) — not a bug fix itself, approve-only. CI green, trusted backend author.
kodjima33
left a comment
There was a problem hiding this comment.
Re-affirming: test-only addition (+37/-0) covering 503-vs-409 and shared_from provenance branches. No production code -> approve-only.
|
@kodjima33 this is approved and green — needs a merge when you have a moment. |
kodjima33
left a comment
There was a problem hiding this comment.
test(backend): pure test-coverage addition (503 claim path), no production diff; approve-only

Summary
Reduced to the increment that survives
main.This PR originally rewired
backend/tests/unit/test_shared_action_items.py, whose six tests from #17830 had never passed (TypeError: accept_shared_action_items() got an unexpected keyword argument 'payload'). While it was open,mainlandedcf2471852bdoing the same rewrite against the same handler API, so that work is no longer needed here.What
main's version does not cover is now the whole of this diff — +29 lines, no deletions:try_accept_task_sharereturningNone→ 503. The handler distinguishes Redis being unreachable (None→ 503) from a token already used (False→ 409).maincovers only the 409, so the two could collapse to one status without a test noticing.shared_fromprovenance on each copy. The success test already patchesupsert_action_item_vectorbut never asserts on it or on the copied payload, so the sender linkage and the vector indexing were both unverified.Verification
8 passed (7 on
main, plus the new case).Mutation-checked — each new assertion fails when the handler breaks:
503unavailable →409shared_from.sender_uidset to a wrong valueupsert_action_item_vectorcall removedHandler restored byte-identical afterwards;
git diffonrouters/action_items.pyis empty. The diff is one test file.Failure class
Failure-Class: FC-fixture-mock-signature-drift
The branch still carries the original
fix:commit that wired the tests to the handler, so the class stays declared.cf2471852bonmainnow covers that wiring; what this PR adds on top is coverage only and changes no production behavior.Product invariants affected
none — tests only.