fix: V1 log API endpoints silently drop logs for deleted workflows#3476
fix: V1 log API endpoints silently drop logs for deleted workflows#3476MaxwellCalkin wants to merge 1 commit intosimstudioai:mainfrom
Conversation
The V1 public API log endpoints used innerJoin with the workflow table, which silently dropped logs for deleted workflows. The internal API endpoints already correctly use leftJoin. This aligns the V1 endpoints with that pattern. Changes: - v1/logs/route.ts: innerJoin -> leftJoin, handle null workflow fields - v1/logs/[id]/route.ts: innerJoin -> leftJoin, fix permissions join to use workflowExecutionLogs.workspaceId instead of workflow.workspaceId (which is null for deleted workflows), handle null workflow fields - v1/logs/executions/[executionId]/route.ts: same innerJoin -> leftJoin and permissions join fix Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR SummaryMedium Risk Overview The Written by Cursor Bugbot for commit 74ef139. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| createdAt: log.workflowCreatedAt, | ||
| updatedAt: log.workflowUpdatedAt, | ||
| } | ||
| const workflowSummary = log.workflowName |
There was a problem hiding this comment.
Truthiness check for deleted workflow detection is inconsistent
Low Severity
The deleted-workflow check in v1/logs/[id]/route.ts uses JavaScript truthiness (log.workflowName) while v1/logs/route.ts uses nullish coalescing (log.workflowName ?? 'Deleted Workflow'). An empty-string workflow name would cause the [id] endpoint to show 'Deleted Workflow' for an existing workflow, while the list endpoint would correctly pass the empty string through. The internal API uses log.workflowId for this check, which is more reliable since it comes from workflowExecutionLogs (set to null on delete) and isn't subject to empty-string falsiness.
Additional Locations (1)
Greptile SummaryThis PR fixes three V1 public API log endpoints ( Key changes:
Confidence Score: 5/5
Sequence DiagramsequenceDiagram
participant Client
participant V1LogsAPI
participant DB_workflowExecutionLogs
participant DB_workflow
participant DB_permissions
Client->>V1LogsAPI: GET /api/v1/logs?workspaceId=...
V1LogsAPI->>DB_workflowExecutionLogs: SELECT logs
DB_workflowExecutionLogs-->>DB_workflow: LEFT JOIN (was innerJoin)
Note over DB_workflow: Deleted workflow → null fields (not dropped)
DB_workflowExecutionLogs-->>DB_permissions: INNER JOIN on workflowExecutionLogs.workspaceId
Note over DB_permissions: Auth uses log's own workspaceId (was workflow.workspaceId)
DB_permissions-->>V1LogsAPI: Results (includes deleted-workflow logs)
V1LogsAPI-->>Client: { name: "Deleted Workflow" } for deleted workflows
Last reviewed commit: 74ef139 |


Summary
The V1 public API log endpoints (
/api/v1/logs,/api/v1/logs/[id],/api/v1/logs/executions/[executionId]) useinnerJoinwith theworkflowtable, which silently drops all logs for workflows that have been deleted. This is inconsistent with the internal API endpoints (/api/logs,/api/logs/[id]) which correctly useleftJoin.Impact:
GET /api/v1/logs— omits logs for deleted workflows from the list (data silently disappears)GET /api/v1/logs/[id]— returns 404 for logs whose workflow was deletedGET /api/v1/logs/executions/[executionId]— returns 404 for executions whose workflow was deletedAdditionally, the
[id]andexecutions/[executionId]endpoints join permissions viaworkflow.workspaceId, which would benullwhen the workflow is deleted — breaking the authorization check entirely. The internal API correctly usesworkflowExecutionLogs.workspaceIdfor this.Changes
v1/logs/route.ts:innerJoin→leftJoinfor workflow table; handle nullworkflowName/workflowDescriptionwith fallback to'Deleted Workflow'v1/logs/[id]/route.ts:innerJoin→leftJoinfor workflow table; fix permissions join to useworkflowExecutionLogs.workspaceIdinstead ofworkflow.workspaceId; handle null workflow fields in responsev1/logs/executions/[executionId]/route.ts: sameinnerJoin→leftJoinand permissions join fixAll changes align the V1 public API with the patterns already used by the internal API (
/api/logs/*).Test plan
GET /api/v1/logs?workspaceId=...includes logs for deleted workflowsGET /api/v1/logs/[id]returns log data (not 404) when the workflow has been deletedGET /api/v1/logs/executions/[executionId]returns execution data (not 404) when the workflow has been deleted"Deleted Workflow"as the workflow name🤖 Generated with Claude Code