Files
outline/server/commands
Tom MoorandClaude Opus 5 6f8072eb68 fix: Avoid duplicate key errors when re-creating attachments by id (#13317)
Import tasks pass a known id to attachmentCreator so a retry can resume,
relying on a caught UniqueConstraintError to skip attachments that already
landed. The file was uploaded to storage before the insert though, so every
skipped attachment was re-uploaded in full and then orphaned, as the storage
key was derived from a fresh uuid rather than the supplied id.

Return the existing attachment before touching storage when the id is already
in use, and derive the key from the supplied id so a collision overwrites the
same object instead of leaking a new one. The lookup is scoped to the team, so
an id belonging elsewhere still falls through to the insert and collides there
as before.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-05 21:08:24 -04:00
..
2026-03-14 23:02:20 -04:00