cms icon indicating copy to clipboard operation
cms copied to clipboard

Getting "This URI has already been taken" when adding elements to a collection

Open taylorcammack opened this issue 4 years ago • 7 comments

Bug Description

Getting a "This URI has already been taken" message when saving an entry to a specific collection. Have tested a couple other collections and am able to save entries correctly. The collection in question has 27 entries. Permissions look OK. Looked through the content and nothing seems garbled. No publish dates enabled and not orderable, so no tree is being generated.

What I've done so far:

  • reverted Statamic as far as 3.1.26, testing on each version
  • Removed all the existing entries from collection
  • cleared all caches

Any ideas where to start looking?

Environment

Statamic 3.1.29 Pro Laravel 7.30.4 PHP 7.4.19 aryehraber/statamic-captcha 1.5.2 aryehraber/statamic-color-extractor 1.1.2 rias/statamic-data-import 1.1.2 spatie/statamic-responsive-images 2.7.1 webographen/statamic-dynamic-token 1.0.0

taylorcammack avatar Jul 20 '21 16:07 taylorcammack

Does that collection have a route?

jasonvarga avatar Jul 20 '21 16:07 jasonvarga

Ahh yes, that was it 😬

Had recently changed the route to {mount}/{id} to get that collection hooked up for a special use-case with the site search. Works great on the front-end, but I guess the CP doesn't like it – maybe there's a different way the route should be written?

taylorcammack avatar Jul 20 '21 16:07 taylorcammack

Are you getting that validation error just when creating new entries? Or also when editing existing entries?

jasonvarga avatar Jul 20 '21 16:07 jasonvarga

Looks like just when creating new entries. I can update existing entries, including changing the slug, and it works fine

taylorcammack avatar Jul 20 '21 16:07 taylorcammack

Cool, I had a feeling. I'm guessing it's because when it tries to validate the uri, it doesn't have an id at that point. Thanks!

jasonvarga avatar Jul 20 '21 17:07 jasonvarga

I'm in a similar context:

  • I have three collections (Films, Stills, Other) that all have a field archive_uuid
  • archive_uuid is random and auto-generated by Uuid (add-on)
  • The route on each collection is: /archive/{archive_uuid}

Question: Will Statamic detect whether the URI is unique when the entries are created?

I ask as although the probability is very low that the same archive_uuid would be created, it'd be nice to know what will happen if that unlikely event occurs.

wesort avatar Mar 24 '22 15:03 wesort

I'm having this behavior with disabled slug field...

But thanks to the workaround mentioned here https://github.com/statamic/cms/issues/5500 it works now.

j3ll3yfi5h avatar Aug 05 '22 16:08 j3ll3yfi5h

I'm going to close this issue now since {id} no longer causes issues in collection routes, thanks to #9035.

Question: Will Statamic detect whether the URI is unique when the entries are created?

Yes, it will do 👍

I'm having this behavior with disabled slug field... But thanks to the workaround mentioned here https://github.com/statamic/cms/issues/5500 it works now.

I'm not sure I completely understand the issue with disabled slug fields. What was your collection route (if you can remember 😆 )?

Glad to hear you found a workaround though.

duncanmcclean avatar Apr 08 '24 14:04 duncanmcclean