Error while saving single type: Invalid input data. Please verify unique constraints

Hello,

I have a problem with saving a simple single type.

I created two nearly similar single types:

{
  "kind": "singleType",
  "collectionName": "activity_carousels",
  "info": {
    "name": "ActivityCarousel"
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": false
  },
  "attributes": {
    "title": {
      "type": "string"
    }
  }
}

{
  "kind": "singleType",
  "collectionName": "city_carousels",
  "info": {
    "name": "CityCarousel"
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": false
  },
  "attributes": {
    "title": {
      "type": "string"
    }
  }
}

When I try to save the city carousel in admin I got the following error: Invalid input data. Please verify unique constraints.

I don’t have this problem with the activity carousel. And when I create another single type with same settings and name it just carousel I also don’t get this error.

I don’t get and understand it. I there some strange naming issue? I don’t know how I can find the error. In network requests I also see an error on edit page for city carousel:

Request URL: http://localhost:1337/content-manager/single-types/application::city-carousel.city-carousel
Request Method: GET
Status Code: 404 Not Found

Thanks for some help!

Best regards,

Timo

I had a similar issue but not sure if it’s related. You can try two different things…

First, you can try “unique”: “false” for the field you’re having a problem with. I had to do this in my case. To find out more from your error, you can find verbose error information in the Chrome Web Dev tools on the front end in your dev environment. It’s actually been very helpful over time to see what error data can come across through the dev environment.

Hope it helps!

Thanks for your reply.

I don’t know for which field this error appears because no field is marked and the error appears in a popover.

But I added the unique-false to the city-carousel.settings.json (now the model has some fields more):

{
  "kind": "singleType",
  "collectionName": "city_carousels",
  "info": {
    "name": "CityCarousel",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": false
  },
  "attributes": {
    "title": {
      "type": "string",
      "unique": false
    },
    "intro_text": {
      "type": "richtext",
      "unique": false
    },
    "finish_text": {
      "type": "richtext",
      "unique": false
    },
    "cities": {
      "collection": "city",
      "unique": false
    }
  }
}

But this has no effect - it’s still the same error.

When I enter the edit page for the singe type I get the following error:

GET http://localhost:1337/content-manager/single-types/application::city-carousel.city-carousel 404 (Not Found)

When I try to edit/save my data I get the following error:

PUT http://localhost:1337/content-manager/single-types/application::city-carousel.city-carousel 400 (Bad Request)

{statusCode: 400, error: “Bad Request”, message: “Invalid input data. Please verify unique constraints”}

  1. error: “Bad Request”

  2. message: “Invalid input data. Please verify unique constraints”

  3. statusCode: 400

  4. proto: Object

  5. {error: {,…}}

  6. error: {,…}

1. contentType.attributes.finish_text: ["contentType.attributes.finish_text field cannot have keys not specified in the object shape"]

  1. 0: "contentType.attributes.finish_text field cannot have keys not specified in the object shape"

2. contentType.attributes.intro_text: ["contentType.attributes.intro_text field cannot have keys not specified in the object shape"]

  1. 0: "contentType.attributes.intro_text field cannot have keys not specified in the object shape"

Hope this error information helps.

I also checked the permissions, but my admin user is the super admin and has permission to edit this single type.

I just created a new single type “AnotherCarousel” with exact same fields as my CityCarousel and I don’t have any problems to save this. I don’t understand the problem…

Best regards,

Timo

I don’t find a solution for this but I used another way to structure my data model so this problem is not longer relevant for me.

i had the same error. i had previously created a singe type data with 2 text fields and then i added 2 more text fields to the same single type data, when i tried to fill the newly added text fields it showed me the error, so i tried deleting the whole entry and started filling all the text fields once again, all at once, again and it worked. a solution you might try

Strapi team, any advice here?

We’ve hit this in our testing environment multiple times and it’s the #1 source of concern for deploying changes to production. When this issue strikes it makes it impossible to edit existing content – can’t save any changes.

Besim’s report above seems to indicate that there’s something about model (and DB) history that can cause it. We’re reading cosole logs and DB logging and don’t see any indication of which constraint Strapi thinks is being violated.

FWIW the current model I’m seeing this happen on only has a single unique field and that field definitely isn’t the cause (can’t save existing content no matter what I enter in that field).

1 Like

Any news on this one? I am running into the same issue over and over again.