Skip to content

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

Merged
priosshrsth merged 1 commit into
productionfrom
main
Aug 7, 2026
Merged

OUT-4027 | Fix 500 when deleting a task whose label row is missing (#…#1398
priosshrsth merged 1 commit into
productionfrom
main

Conversation

@priosshrsth

Copy link
Copy Markdown
Collaborator

…1397)

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.

Changes

  • ...

Testing Criteria

  • Test Criterias (explain how you did testing for this PR mentioning all the cases you tested for) [Loom](video link going through the test criteria)

Notes

  • Dependencies on other PRs, any required changes in config/setup to test behaviour, or links to external documents, threads, etc -- if any of them are required

Impact & Surface Area of Change

  • An overview of components behaviour to be looked at for unintended breaks after the changes. This will make regression testing easier and efficient.

…1397)

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.
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

OUT-4027

@vercel

vercel Bot commented Aug 7, 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 7, 2026 4:49am

Request Review

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown

Greptile Summary

The PR prevents task deletion from failing when its label mapping is already absent at lookup time and adds focused unit coverage.

  • Returns early when label lookup produces no row.
  • Dereferences the label ID only after the null guard.
  • Tests both successful deletion and the already-missing-row case.

Confidence Score: 4/5

The PR should not merge until label cleanup is idempotent across the full operation, because concurrent cleanup can still abort task update or deletion transactions.

The new guard fixes an initially absent row but retains a find-then-delete race in transaction-backed task flows, allowing a concurrent deletion to produce the same server failure.

Files Needing Attention: src/app/api/label-mapping/label-mapping.service.ts

Important Files Changed

Filename Overview
src/app/api/label-mapping/label-mapping.service.ts Adds the intended missing-row guard, but the two-query deletion still fails if a concurrent transaction removes the row after lookup.
src/app/api/label-mapping/label-mapping.service.test.ts Adds correctly configured unit coverage for a present mapping and one already absent when lookup runs.

Reviews (1): Last reviewed commit: "OUT-4027 | Fix 500 when deleting a task ..." | Re-trigger Greptile

Comment on lines +178 to 180
if (!currentLabel) return
await this.db.label.delete({
where: {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Non-idempotent label deletion race

If two task updates or deletions concurrently remove the same label mapping, both calls can pass findFirst, after which the second delete fails because the selected ID is gone, aborting its enclosing task transaction and returning the same class of 500 this change intends to prevent.

Knowledge Base Used: Workspace Settings & Configuration APIs

@priosshrsth
priosshrsth merged commit eb81caf into production Aug 7, 2026
3 checks passed
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