[SOLVED] Cloning fails silently on Content that contains a Unique field

I have…

  • [x] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

When cloning content with a unique field, the server responds with a 400 Bad Request but the UI does nothing.

{"message":"Failed to create content.","details":["id: Another content with the same value exists."],"statusCode":400}

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [x] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

When I try to clone content with a unique field, the clone operation silently fails.

Expected behavior

At a minimum, I would expect a UI notification of the error message.

However, it would be fantastic if the clone succeeded and any field marked as unique was appended with something like a guid to guarantee uniqueness.

Minimal reproduction of the problem

  1. Create and publish a new schema with a unique string named id
  2. Create a content on that schema with id foo
  3. Use the UI to clone that content. This fails silently

Environment

  • [x] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 4.0.2.0

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Thanks, I will add a error notification.

Thanks for the quick reply! Any comment on the possibility of forcefully randomizing any fields defined as unique in the new content? Or perhaps adding an intermediate step to define new values for those unique fields?

Random values are critical because you could have webhooks or so that have assumptions about certain formats or pattern validation that you would then fail. But I guess I can add the intermediate step.

1 Like

What if, instead of an intermediate step, the Clone operation doesn’t try to save the new content, but instead opens up the editor in “new” mode and populates all fields based on the cloned-from content? Then you wouldn’t have to actually know or care about which fields are unique, and all Clone operations would require you to manually save, and therefore be subject to uniqueness validation automatically?

Yes, this was my idea when you mentioned “intermediate step”

1 Like

I guess I can implement this tomorrow.

Update: PR is done: https://github.com/Squidex/squidex/pull/473