authgear-server icon indicating copy to clipboard operation
authgear-server copied to clipboard

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

Open buildbro opened this issue 1 year ago • 1 comments

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

  • Version: SaaS

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,
    }
}
  1. Send the request
  2. 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):

  • Device: [e.g. Desktop, Smartphone]
  • OS: [e.g. Windows, iOS]
  • Browser [e.g. chrome, safari]
  • Browser Version [e.g. 22]

Additional context Add any other context about the problem here.

buildbro avatar May 06 '24 10:05 buildbro