Skip to content

OUT-4027 | Fix 500 when deleting a task whose label row is missing - #1397

Merged
priosshrsth merged 1 commit into
mainfrom
anit/out-4027-debug-task-delete-issue
Aug 7, 2026
Merged

OUT-4027 | Fix 500 when deleting a task whose label row is missing#1397
priosshrsth merged 1 commit into
mainfrom
anit/out-4027-debug-task-delete-issue

Conversation

@priosshrsth

@priosshrsth priosshrsth commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Deleting a task 500'd with PrismaClientValidationError … Argument where of type LabelWhereUniqueInput needs at least one of id. OUT-4027

deleteLabel passed id: currentLabel?.id straight into label.delete, so when the findFirst matched nothing Prisma received { id: undefined } and threw, failing the whole delete transaction. One guard, plus a test.

What to look at

  • label-mapping.service.ts — the early return. The label row being absent is now a no-op; Labels is a next-number registry, so a missing row costs nothing at delete time.

Verified: new unit test covers both branches. yarn tsc and yarn lint:check clean. Unit suite passes except withErrorHandler / authenticate, which fail identically on main.
Not verified: no manual run of the delete endpoint.

Not fixed here — OUT-4029: rows go missing in the first place because softDeleteAllSubtasks matches Tasks and Labels by label string with no workspace scope. Prod has 3,631 label strings shared across 2+ workspaces (THE10-001 spans 121), 747 live tasks that hit this 500, and 2,390 tasks soft-deleted as collateral by the unscoped task.deleteMany. This PR stops the 500; it does not stop the collateral deletes, so those counts keep climbing until OUT-4029 lands.

🤖 Generated with Claude Code

@linear-code

linear-code Bot commented Aug 6, 2026

Copy link
Copy Markdown

OUT-4027

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tasks-app Ready Ready Preview Aug 6, 2026 12:15pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

The PR prevents task deletion from failing when its label registry row is already absent.

  • Adds an early return before deleting a missing label row.
  • Adds unit coverage for both the existing-row and missing-row branches.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains within the eligible follow-up review scope.

Important Files Changed

Filename Overview
src/app/api/label-mapping/label-mapping.service.ts Adds the intended missing-label no-op guard before issuing the Prisma delete.
src/app/api/label-mapping/label-mapping.service.test.ts Covers deletion of an existing label row and the no-op behavior when no row is found.

Reviews (2): Last reviewed commit: "OUT-4027 | Guard deleteLabel against an ..." | Re-trigger Greptile

@priosshrsth
priosshrsth force-pushed the anit/out-4027-debug-task-delete-issue branch from 558979a to e797c97 Compare August 6, 2026 12:09
@priosshrsth priosshrsth changed the title OUT-4027 | Fix task delete: key subtask deletion on ids, stop deleting Labels rows OUT-4027 | Guard deleteLabel against an already-deleted label row Aug 6, 2026
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project tasks-app with the following error:

Deploying Serverless Functions to multiple regions is restricted to the Pro and Enterprise plans.

Learn More: https://vercel.link/multiple-function-regions

@priosshrsth

Copy link
Copy Markdown
Collaborator Author

@greptileai the pr has changed a lot. Re review again.

deleteLabel passed `id: currentLabel?.id` straight into label.delete, so when
findFirst matched nothing Prisma got `{ id: undefined }` and threw
PrismaClientValidationError, failing the whole delete transaction. Return early
instead.

Rows go missing because softDeleteAllSubtasks soft-deletes Labels rows by label
string, which is not unique across workspaces. Fixed separately in OUT-4029.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@priosshrsth
priosshrsth force-pushed the anit/out-4027-debug-task-delete-issue branch from e797c97 to 65ba2e5 Compare August 6, 2026 12:14
@priosshrsth priosshrsth changed the title OUT-4027 | Guard deleteLabel against an already-deleted label row OUT-4027 | Fix 500 when deleting a task whose label row is missing Aug 6, 2026

@SandipBajracharya SandipBajracharya left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@priosshrsth
priosshrsth merged commit 8f63a1b into main Aug 7, 2026
3 checks passed
priosshrsth added a commit that referenced this pull request Aug 7, 2026
…1397) (#1398)

deleteLabel passed `id: currentLabel?.id` straight into label.delete, so when
findFirst matched nothing Prisma got `{ id: undefined }` and threw
PrismaClientValidationError, failing the whole delete transaction. Return early
instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants