Repository navigation
Description
Summary
POST /api/app/files/reject-blob deletes the stored bytes of an upload that a task already lists as an attachment. Afterwards the task still shows the file, /files/urls answers url: null for it, and per #4085 every run start for that task fails as input_missing.
The cause is in the reclaim lane:
- It ignores the vouch stamp.
deleteRejectedUploadBlobproves "this blob was never bound" withconsumeUploadIntent, which ignores the intent'sbound_at_msstamp. fix(platform): close eight low-severity reliability leaks and races #3191 introduced that stamp precisely because "unconsumed is not unbound". - It skips fix(platform): keep task attachment bytes alive and name a gone one #4085's holder check. It never asks
taskHoldsBlobRef, the predicate fix(platform): keep task attachment bytes alive and name a gone one #4085 put into every other lane that decides "may the bytes go?".
Reach is low. The shipped UI registers every upload before attaching it, and registration consumes the intent, so the UI-shaped flow is protected (case P1 below). It takes a session-API client that attaches a POST /files/upload ref to a task without registering it, then reclaims that same ref within the 2-hour intent TTL. The consequence, once reached, is permanent loss of the attachment's bytes.
Source and environment
- Source:
origin/mainb7d1c1d7ef1b6755fad8a75da122159d8d3a6138(fix: name budget-rule keys, explain empty chat replies, land docs labels #4012). The reclaim lane and the task door are unchanged since fix(platform): keep task attachment bytes alive and name a gone one #4085 (1f0009cc3). - Local native stack, owned by the TALE-358 local-qa occurrence 2026-10-03 00:15 Zurich, run
820db997-15c0-43a4-a678-23bd1714628f:- Database: PostgreSQL 16.15 (PGDG bookworm) with pg_search 0.22.6, pgvector 0.8.6 and pg_cron 1.6.7, initialized like
tale-db, on127.0.0.1:55370. - App:
bun scripts/dev.ts(backend127.0.0.1:3656, Vitelocalhost:3651), with egress to a dead proxy. - Object store: a local S3 test double on
127.0.0.1:59070that logs every request, so each DELETE the backend sends is visible. - Data: synthetic users and organization
proof-b1-murjho5n.
- Database: PostgreSQL 16.15 (PGDG bookworm) with pg_search 0.22.6, pgvector 0.8.6 and pg_cron 1.6.7, initialized like
Impact
A task attachment's bytes are deleted while the task keeps listing the file. Nothing warns, the bytes can't be recovered, and the task can't run until someone re-uploads the file. This is the same user-visible end state that #4085 fixed for the file-delete, trash-purge and sweep lanes.
The same rule also covers the other lanes that bind without consuming, the document multi-bind and outbound mail attachments (#3191). Those weren't exercised here; see Limits.
Root cause
All references are to services/platform at b7d1c1d7e.
- The task door binds without consuming the intent.
assertOwnedTaskAttachments(backend/domains/tasks/service.ts:1239-1257) callsfirstForeignUpload→ownsUploadedBlob(backend/domains/files/upload-intents.ts:146-169). That stampsbound_at_msand leavesconsumed_at_msNULL. - The reclaim lane then treats the open intent as never bound.
deleteRejectedUploadBlob(backend/domains/files/service.ts:846-872):- looks only for an
app.file_metadatarow; - calls
consumeUploadIntent(upload-intents.ts:113-131), which matches any unconsumed, unexpired intent of the caller whateverbound_at_mssays; - then deletes the object.
- looks only for an
- The sibling lanes honour the rules this one skips:
sweepUploadIntents(upload-intents.ts:200-) never reclaims a ref withbound_at_msset;deleteFile(files/service.ts:685-700) keeps bytes whiletaskHoldsBlobRefis true.
Deterministic reproduction
The probe is scripts/b1-reject-blob.ts, retained in the TALE-358 evidence archive TALE-358-local-qa-r20261003T0015-evidence.tar.gz together with its log, the S3 double's request log and the database readback. Every case runs as one synthetic owner (plus a synthetic member for C2), through the session doors under /api/app.
| Case | Steps | reject-blob answer |
S3 DELETEs | Bytes after |
|---|---|---|---|---|
| C1 control | POST files/upload, then reject |
deleted: true |
1 | gone (expected) |
| C2 refusal | owner uploads; a member rejects that ref | deleted: false |
0 | kept |
| C3 refusal | UI lane: blob-upload → PUT → files/register, then reject |
deleted: false |
0 | kept |
| P1 UI-shaped | UI lane upload, POST tasks with it as an attachment, then reject |
deleted: false |
0 | kept |
| C4 #4085 predicate | UI lane upload, attach to a task, DELETE files/:fileId |
200 | 0 | kept (the task holds the ref) |
| P2 defect | POST files/upload, POST tasks with it as an attachment (the task lists it), then reject |
deleted: true |
1 | gone; the task still lists it; POST files/urls → url: null |
Readback after P2: P2's app.upload_intents row has bound_at_ms set, by the task bind, and consumed_at_ms set, by the reject.
Expected
The rejected-upload reclaim deletes only bytes that nothing holds. A ref that a task, a document or an outbound message bound or vouched for answers deleted: false, and its bytes stay.
Observed
P2: {"deleted": true}. The backend sent DELETE /tale358-r0015/proof-b1-murjho5n/2b8e419f-… to the store (logged with existed: true), while app.tasks.attachments still lists s3:proof-b1-murjho5n/2b8e419f-….
Acceptance checks
- The reclaim refuses held refs.
deleteRejectedUploadBlobrefuses when the caller's intent carriesbound_at_ms, or any holder check is true. At minimum that istaskHoldsBlobRef,app.documents.file_refandapp.file_metadata, the same checksdeleteFileuses. Preferably there is one shared rule, so the next holder can't be missed again. - A regression case for P2 passes (upload → task attach → reject →
deleted: false, bytes kept). C1, C2 and C3 keep their current results. Use the real-Postgresbackend:integrationlane next to fix(platform): keep task attachment bytes alive and name a gone one #4085's task-holder lanes, with an object store, so a DELETE would be observed. - Optional: consume or close the intent at the task bind, so a later reclaim can't match it. If that's the chosen fix, document how it interacts with the non-consuming multi-bind lanes (fix(platform): close eight low-severity reliability leaks and races #3191).
- Out of scope: the user-erasure lane's documented behaviour (fix(platform): keep task attachment bytes alive and name a gone one #4085 "Out of scope").
Limits
- Object store: a local S3 test double that ignores authentication, not MinIO. It shows the DELETEs the backend sends; the server-side code path is the real one.
- Database differences from
tale-db:- PostgreSQL 16.15 on bookworm, while
tale-dbbuildsFROM postgres:16-trixie; - pgvector 0.8.6, while the image has 0.8.1;
- no pg_ivm, which Tale doesn't use.
- PostgreSQL 16.15 on bookworm, while
- Not exercised: the outbound mail and document multi-bind lanes. They share the non-consuming proof, but documents also register a file row, which C3 shows is honoured.
- No reachable UI path: P1 shows the shipped UI flow is protected, and REST v1 carries no task attachments (
backend/rest/error-codes.test.ts:221).
Activity
yannickmonney commentedon Oct 3, 2026
Source triage at
358f69107e3725e7e1e30f0c9e0eaf3a2410da74confirms the reported reclaim gap remains. This is an independent source read, not another reproduction.For the repair, preserve the legitimate callers:
registerUploadalso usesconsumeUploadIntent, whileownsUploadedBlobdeliberately supports non-consuming multi-bind and consumed-but-unexpired intents. A blanketbound_at_ms IS NULLcondition on the shared registration consumer would change that contract; keep the unbound-only requirement specific to reclamation and reuse the existing holder predicate.Also state the bind/reclaim ordering guarantee explicitly. The ownership stamp currently ignores
consumed_at_ms, so merely checking the stamp once before deletion does not by itself prove that a later bind cannot win. That is a source-derived concurrency concern, not an independently reproduced second finding. Cover the chosen boundary with the real-Postgres regression/control lane, or clearly record the remaining limit; no production experiment is requested.The fleet manager has been asked to prioritize deduplicated intake for this issue. Root is not starting a competing implementation.
yannickmonney commentedon Oct 3, 2026
QA recheck after #4109, on
main3b23bd2cb(TALE-358 local-qa, runbab9f790-2159-4a21-88a7-4b46daffdf28; the reporter's own reproduction, replayed natively; I didn't write #4109).Setup: the same doors and S3 test double as the original report, with its own PostgreSQL
:55372, the app on:3671/:3676and synthetic data. Every DELETE the backend sends is logged.b7d1c1d7e)3b23bd2cb)files/upload→ task attach →reject-blobdeleted: true, 1 DELETE, bytes gonedeleted: false, 0 DELETEs, bytes kept; the task still lists the refdeleteFileon a task-held refTASK_ATTACHMENT_NOT_OWNEDreject-blobfalseVerdict: the original reproduction no longer reproduces, and the nearby controls hold.
Correction to this issue's evidence:
POST files/urlsanswersurl: nullfor P2's ref even with its bytes present. It resolves file rows only (files/routes.ts:500-508), and an API-shaped upload has none. So that line was not evidence of the deletion. The S3 DELETE and the HEAD 404 were.Same class, one more lane: the product image release still keeps its own holder copy, the source follow-up agent #2 raised on TALE-487. It is confirmed natively in #4110.