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).

4 Likes

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

1 Like

same error here. strapi v3.6.8 : (

Same issue on Strapi v3.6.3

In my case a the database row had gone missing for the field that I’d added. Reinstating the db row fixed the issue.

It is happening with me also and looks like the only option is to clear the whole page content and again.

I agree with your Jesseko. I have faced this issue several times and it forces us to delete all data and add again. Which creates a problem.

I do have this weird error. I

I’m facing the same error. Do we have a fix for this?

This solved it for me after migrating somewhat manually from Mongo to Postgres. Basically the index count gets shot and this resets it to what it should be:

SELECT setval(’_id_seq’, COALESCE((SELECT MAX(id)+1 FROM your_table), 1), false);

In my case, I see this error when I try to save some Japanese characters that my table’s column doesn’t support. Change my db character set to utf8, and collation to utf8_unicode_ci does solve the problem for me.

Hi, in my case it was due to a max length existing on a column even though the Strapi server didn’t think one was set. There’s some more details here: