Skip to content

[6.x] Fix "Discard and use existing file" adding an asset that doesn't exist - #15716

Open
mynetx wants to merge 1 commit into
statamic:6.xfrom
mynetx:fix/use-existing-upload-sanitized-name
Open

mynetx wants to merge 1 commit into
statamic:6.xfrom
mynetx:fix/use-existing-upload-sanitized-name

Conversation

@mynetx

@mynetx mynetx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

When an upload conflicts with an existing file and you choose "Discard and use existing file", the assets field adds an asset that doesn't exist. It shows a generic icon with a path like assets::Repro Image.JPG, and saving fails with "Asset [...] not found".

The server sanitizes the filename before checking for the duplicate (spaces become dashes, and it's lowercased by default), but the field built the existing asset's id from the original filename. So uploading Repro Image.JPG when repro-image.jpg exists added assets::Repro Image.JPG.

The 409 response now includes the existing asset's id, and the assets fieldtype and the asset browser use it instead of rebuilding it from the filename.

Before After
Field 15556-before 15556-after
Save 15556-before-save-error Saves

Fixes #15556

🤖 Generated with Claude Code

…ad conflict

The server sanitizes the uploaded filename before checking for a duplicate,
but the client built the existing asset's id from the raw filename. The 409
response now includes the existing asset's id and both the fieldtype and the
asset browser use it.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Assets field: Discard and use existing file issue

1 participant