How to configure Strapi to output errors related to uniqueness of the UID?

System Information
  • OS: Ubuntu 20.04
  • Strapi Version: 3.4.3
  • Node Version: 14.15.1
  • Database: PostgreSQL

How to configure Strapi to output errors related to the uniqueness of the UID?
At present, if I try to add data having the same UID in the Collection using API, it throws Internal Server Error but doesn’t even mention the error about UID.

{
    "statusCode": 500,
    "error": "Internal Server Error",
    "message": "An internal server error occurred"
}

Can you open a bug report on github with the server side logs?

@DMehaffy I am seeing this on my local but nothing as an error in the terminal or in the output window.
Could it be that the error is happening because Database is rejecting this input?

@DMehaffy

OK so I checked the PostgreSQL logs and turns out it indeed is.

ERROR:  duplicate key value violates unique constraint "tvsr_user_lists_slug_unique"
DETAIL:  Key ("Slug")=(first-list) already exists.

Generally, when I enter a duplicate value, I do see the Unavailable error in Admin.
image

But using API, it still just gives me the error:

{
    "statusCode": 500,
    "error": "Internal Server Error",
    "message": "An internal server error occurred"
}
1 Like

@DMehaffy I have created the issue in GitHub:
Duplicate UID doesn’t show the respective error in API call · Issue #9168 · strapi/strapi (github.com)

1 Like