authgear / authgear-server

Open source alternative to Auth0 / Firebase Auth
https://www.authgear.com
Apache License 2.0
81 stars 37 forks source link

Auth Flow API Returns 500 internal error when the request body is invalid/not properly formatted #4199

Open buildbro opened 4 months ago

buildbro commented 4 months ago

Describe the bug I ran a few invalid inputs intentionally to help me with documenting the Authentication Flow API error responses.

In the process, I ran into the following issue:

Improper inputs such as poorly formatted JSON (e.g including a trailing comma in JSON) will return a 500 internal error that looks like this:

"error": {
        "name": "InternalError",
        "reason": "UnexpectedError",
        "message": "unexpected error occurred",
        "code": 500
    }

Authgear Version

To Reproduce Steps to reproduce the behavior:

  1. Initiate an HTTP request to the authentication flow endpoint (/api/v1/authentication_flows/states/input)
  2. Add a trailing comma to anywhere in the request body like so:
    {
    "state_token": "authflowstate_ZK9ZENACTQDGNM1B2741CREF0ZBRR9WD",
    "input": {
        "index": 0,
    }
    }
  3. Send the request
  4. See error in HTTP response.

Expected behavior Expect an error message about invalid input

Screenshots

SCR-20240506-kpcm

Client Env (if applicable, please complete the following information):

Additional context Add any other context about the problem here.

linear[bot] commented 4 months ago

DEV-1276 Auth Flow API Returns 500 internal error when the request body is invalid/not properly formatted