Skip to content

Bug: a slow task upload removes an attachment saved while it was pending #3904

Closed

Description

@yannickmonney

Two attachment batches on the same task can overwrite each other. If a slow upload starts first and another upload finishes and saves while it is waiting, finishing the slow upload removes the already-saved file from the task.

Severity: P2 (successfully saved attachment silently removed).
Source: 9ea59724df24d62729a9360f3902d964dab39b3e.

Local reproduction

  1. Open a writable ordinary task with prior.txt attached.
  2. Add slow.txt and hold its upload response pending.
  3. While that upload is in progress, add fast.txt as a separate batch. The Add attachments control remains enabled.
  4. Finish the fast upload and allow its task update/readback to complete. The task now displays prior.txt and fast.txt.
  5. Finish the slow upload.

Expected: the task keeps prior.txt, fast.txt and slow.txt, or prevents/serializes overlapping batches without losing accepted changes.

Actual: the second save from the slow batch contains only prior.txt and slow.txt. After readback, fast.txt disappears even though its upload and preceding task save succeeded. No discard/removal was requested and no conflict is shown.

Root cause

onUploadAttachments closes over the task at the start of the upload, awaits uploadFiles, then full-replaces attachments using that old snapshot (services/platform/app/features/tasks/components/task-modal.tsx:1316-1328). The real useFileUpload supports concurrent batches and accounts for their reservations, but that does not make the parent's full-replacement writes safe. TaskAttachments receives no disabled value here, so its upload/removal controls remain usable.

The native updateTask contract accepts a replacement list, not an append: it compares the supplied set with current stored refs, writes nextAttachments and releases dropped refs (services/platform/backend/domains/tasks/service.ts:1314-1337,1429-1436). Consequently the missing fast-batch reference is meaningful; the server does not merge it back.

Fix the attachment update concept so an older upload cannot overwrite accepted changes made during its wait. Cover overlap and removal/intervening changes, not only multiple files selected together in one batch.

Evidence and controls

At the source SHA above, 2/2 tests passed in jsdom and 2/2 in real Chromium using actual EditTaskBody, TaskAttachments, shared FileUpload input and actual useFileUpload. Query/write/storage seams are closed synthetic boundaries; unrelated page sections and thumbnail presentation are omitted. The reproduction drives two real file-input selections and controls only upload response timing, then asserts the replacement payloads and resulting UI readbacks:

  • fast save: [old-ref, fast-ref]
  • late slow save: [old-ref, slow-ref]
  • sequential-upload control: [old-ref, first-ref, second-ref]

The isolated mutation seam records accepted payloads and the test supplies their readbacks; no live Postgres/blob write or real task was modified. Native source inspection confirms the full-replacement semantics. Retained evidence: task-attachments-next/overlapping-uploads.probe.test.tsx, overlapping-uploads.browser.probe.test.tsx, and their replay logs. An initial browser fixture import error was corrected before the passing observed run; it is not a product finding.

Dedup: current GitHub searches plus the baseline/additional ledger found no matching task attachment replacement report. #2078 is the upload hook's cross-batch cap/dedup accounting; that logic is present here and does not protect the caller's task snapshot. #3646/#3647 concern chat drafts/message edits. This report is one task attachment concurrency root, not separate findings per interleaving.

Activity

  1. yannickmonney commented on Sep 29, 2026

    @yannickmonney
    ContributorAuthor

    Current-main revalidation — b7f8ca0

    Source: b7f8ca02ec249c004652b1ee52e112d9cdfa53ea. The coordinator independently reran the actual EditTaskBody/TaskAttachments/useFileUpload path in Chromium. Both attachment cases pass: sequential completion preserves the set, while slow B finishing after fast C replaces [A,C] with the stale [A,B] array. Read/upload/update boundaries are synthetic. These two cases passed in a combined log that also retained an unrelated Knowledge fixture-cleanup failure; that Knowledge fixture was subsequently corrected and its separate 2/2 replay passes. No real attachment or record was changed.

    Evidence: /Users/yannick/.codex/notes/tale-1000-additional/current-main-reconciliation/components/replay.log. Installed external dependencies are reused; app/UI/shared source points at the isolated current tree. Browser runs retain the runner/browser version warning. These revalidations add no findings and include no production testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions