Uh oh!
There was an error while loading. Please reload this page.
feat(tasks): enhance delete task functionality with account resolution and access control - #487
Conversation
…n and access control - Updated `registerDeleteTaskTool` to include account ID resolution using `resolveAccountId`, ensuring only authorized users can delete tasks. - Modified `deleteTask` to accept a `resolvedAccountId` parameter, enforcing access control by checking task ownership before deletion. - Introduced `TASK_ACCESS_DENIED_MESSAGE` for clearer error handling when access is denied. - Updated `deleteTaskHandler` to handle access denial responses appropriately. - Adjusted validation schema for task deletion to ensure proper UUID format. This implementation improves security and user feedback during task deletion operations.
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
1 issue found across 7 files
Confidence score: 3/5
- There is a concrete error-handling gap in
lib/mcp/tools/tasks/registerDeleteTaskTool.ts: exceptions fromdeleteTaskcan escape as uncaught handler errors instead of structured tool results. - Because this is a medium-severity (6/10) issue with high confidence, it introduces real user-facing failure risk in delete-task flows, so merge risk is moderate rather than minimal.
- Pay close attention to
lib/mcp/tools/tasks/registerDeleteTaskTool.ts- ensuredeleteTaskfailures are caught and mapped togetToolResultError(...)for consistent tool responses.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/mcp/tools/tasks/registerDeleteTaskTool.ts">
<violation number="1" location="lib/mcp/tools/tasks/registerDeleteTaskTool.ts:45">
P2: Handle `deleteTask` exceptions in the tool callback and return `getToolResultError(...)` so failures are returned as tool results instead of uncaught handler errors.</violation>
</file>
Architecture diagram
sequenceDiagram
participant Client
participant Handler as Task Handler (API/MCP)
participant Auth as Auth Service
participant Logic as deleteTask Logic
participant DB as Database (Supabase)
participant Trigger as Trigger.dev (External)
Note over Client,Trigger: Task Deletion Flow with Access Control
Client->>Handler: DELETE /api/tasks (id)
Handler->>Auth: NEW: resolveAccountId(request/authInfo)
alt Auth Success
Auth-->>Handler: accountId
else Auth Failure
Auth-->>Handler: Error (401/403)
Handler-->>Client: Error Response
end
Handler->>Handler: CHANGED: validate id as UUID
Handler->>Logic: CHANGED: deleteTask(id, resolvedAccountId)
Logic->>DB: Fetch task by id
DB-->>Logic: task record (including account_id)
alt Task Not Found
Logic-->>Handler: Error: Task not found
Handler-->>Client: 404 Not Found
else Task Found
Logic->>Logic: NEW: Check ownership (task.account_id === resolvedAccountId)
alt NEW: Access Denied
Logic-->>Handler: Error: TASK_ACCESS_DENIED_MESSAGE
Handler-->>Client: 403 Forbidden
else Access Granted
Note over Logic,Trigger: Parallel Deletion
par Logic->>DB: deleteScheduledAction(id)
and opt task has trigger_schedule_id
Logic->>Trigger: deleteSchedule(trigger_id)
end
end
Logic-->>Handler: Success
Handler-->>Client: 200 OK / Tool Result Success
end
end
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="lib/mcp/tools/tasks/registerDeleteTaskTool.ts">
<violation number="1" location="lib/mcp/tools/tasks/registerDeleteTaskTool.ts:50">
P1: Do not return raw exception messages from this catch block; it can leak internal error details to clients. Log the original error server-side and return a generic message.
(Based on your team's feedback about avoiding raw exception text in 500 responses.) [FEEDBACK_USED]</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Uh oh!
There was an error while loading. Please reload this page.
- Enhanced the error handling in `registerDeleteTaskTool` to return specific error messages for task not found and access denied scenarios. - Introduced a new constant `TASK_NOT_FOUND_MESSAGE` for clearer error reporting. - Updated the catch block to log unexpected errors and return a generic internal server error message. This change improves user feedback during task deletion operations and ensures better handling of specific error cases.
sweetmantech
commented
Apr 28, 2026
Preview deployment test resultsExercised the preview at ✅ Validation + auth gates (all working)
✅ Happy path + ownership
|
registerDeleteTaskToolto include account ID resolution usingresolveAccountId, ensuring only authorized users can delete tasks.deleteTaskto accept aresolvedAccountIdparameter, enforcing access control by checking task ownership before deletion.TASK_ACCESS_DENIED_MESSAGEfor clearer error handling when access is denied.deleteTaskHandlerto handle access denial responses appropriately.