fix(tasks): DELETE /api/tasks honours the account_id admin override - #805
fix(tasks): DELETE /api/tasks honours the account_id admin override#805sweetmantech wants to merge 1 commit into
Conversation
validateDeleteTaskRequest called validateAuthContext(request) with no override
options, unlike GET/POST/PATCH. An org or admin key could create, read and edit
a member account's task but got 403 deleting it. Hit live 2026-07-29 and
2026-07-30; the workaround was PATCH {enabled:false}.
Adds optional account_id to deleteTaskBodySchema (mirroring updateTaskSchemas)
and forwards it to validateAuthContext, which owns the authorization decision —
this is an auth context, not a raw column override.
Implements docs#283.
chat#1918
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 44 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
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 |
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Bug fix aligning DELETE with existing GET/POST/PATCH behaviour by forwarding the optional account_id override. Focused change with tests, no new auth logic.
Re-trigger cubic
Implements docs#283 and closes the
DELETEoverride row of chat#1918.Merge order: docs#283 first, then this. The docs PR is the contract; this fulfills it exactly.
The bug
validateDeleteTaskRequest.tscalled:while the PATCH sibling (
validateUpdateTaskRequest.tsL47) passes{ accountId: validationResult.data.account_id }.DELETEwas the only task verb missing it, so an org or admin key could create, read and edit a member account's task but got 403 deleting it.Hit live twice — 2026-07-29 removing a duplicate task, and again 2026-07-30 during the task audit. The workaround both times was
PATCH {enabled:false}(whose re-sync also deletes the Trigger schedule, so it is at least drift-free).The fix
deleteTaskBodySchemagains an optionalaccount_id, using the same description wording asupdateTaskSchemasso the two verbs read identically: "Account context for org/API-key rules; authorized via validateAuthContext. Not a raw column override."validateDeleteTaskRequestforwards it tovalidateAuthContext, which keeps ownership of the authorization decision. No new authorization logic is introduced here — a non-admin cross-account delete still 403s, because that check lives invalidateAuthContextand is unchanged.requiredstays["id"]; callers that don't sendaccount_idare unaffected.Tests
RED→GREEN, 2 new tests in
lib/tasks/__tests__/validateDeleteTaskRequest.test.ts:account_idtovalidateAuthContextas the overrideaccount_idwith 400Both confirmed RED before the change (
expected "spy" to be called with…andexpected { …(2) } to be an instance of NextResponse).pnpm exec vitest run lib/tasks→ 16 files, 78 tests, all passpnpm exec eslinton all three touched files → cleanpnpm exec tsc --noEmit→ no errors in any touched fileRemaining verification
The issue's Done-when asks that DELETE with a valid admin
account_idremoves the task and its Trigger schedule, and that a non-admin cross-account DELETE still 403s. Both need exercising against the preview before the row is closed — the unit tests cover the wiring, not the live authorization path.🤖 Generated with Claude Code
Summary by cubic
Fixed DELETE /api/tasks to honor the
account_idadmin/org override, matching GET/POST/PATCH per docs#283. Admin and org API keys can delete member-account tasks; non-admin cross-account deletes still 403.account_idto the delete body and validate it as a UUID.validateAuthContext; no new auth logic introduced.Written for commit 208e9d6. Summary will update on new commits.