Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a new user with an already used e-mail address returns error 400 with no clear status #10026

Closed
3 tasks done
ravolta-io opened this issue Nov 24, 2021 · 4 comments
Closed
3 tasks done

Comments

@ravolta-io
Copy link

ravolta-io commented Nov 24, 2021

Preflight Checklist

Describe the Bug

Registering a new user with a POST to /users works fine, but if the email is already in use Directus just returns a 400 error. When setting LOG_LEVEL="debug", the Directus log shows 'Field "email" has to be unique".
Expected behaviour would be to return the proper error codes so error handling can be correctly implemented on the client side.

Schermafbeelding 2021-11-24 om 14 59 09

To Reproduce

  1. Install Directus with PostGreSQL database
  2. Create a user, either through the REST API or admin dashboard.
  3. Create another user through the REST API with the same email as the one created in step 2.
  4. Observe the received error.

Errors Shown

No response

What version of Directus are you using?

9.0.1

What version of Node.js are you using?

16.13.0

What database are you using?

MySQL

What browser are you using?

React Native / Expo

What operating system are you using?

macOS

How are you deploying Directus?

Google Cloud

@licitdev
Copy link
Member

Directus returns an Error 400 with the following error message in the response body.

{
    "errors": [
        {
            "message": "Field \"email\" has to be unique.",
            "extensions": {
                "code": "RECORD_NOT_UNIQUE",
                "collection": "directus_users",
                "field": "email",
                "invalid": "duplicate@email.com"
            }
        }
    ]
}

Please check on the response body, you may have to surround your API request with Try-catch.

@rijkvanzanten
Copy link
Member

Hey wie hebben we daar! Alles lekker Tristan?

I'll close this for now, as the detailed error can be found in the API response, which in turn allows for proper error handling in the end project.

@ravolta-io
Copy link
Author

ravolta-io commented Dec 1, 2021

@rijkvanzanten Gaat lekker hoor :) Met jou ook zo te merken ;)

We did wrap the whole request in a try-catch, as we do with all our async calls. This is the third project I'm using Directus on and I have not encountered this issue before, only after migrating the current project we are working on to latest Directus version.

I'm putting my colleague on it to try different methods so we can present you with more details and examples.

@rijkvanzanten
Copy link
Member

@ravolta-io that works! I don't think anything changed around error returning or its structure since the early alpha versions, so it should be good from that end.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants