Skip to content

When JWT is incorrect, the returned error should be 400 Bad Request and not 500 #3960

@uaru

Description

@uaru

Description

When the server receives the request authorized with JWT with payload

{
   :sub => username,
   :'_couchdb.roles' => roles,
   :exp => ...,
}

and roles is a string, the server returns error 500 Internal Server Error with

{
  "error": "internal_server_error",
  "reason": "No DB shards could be opened.",
  "ref": ...
}

Steps to Reproduce

curl -X GET --location "https://<couchdb_server>:6984/<db>/<document>" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json; charset=utf-8" \
    -H "Authorization: Bearer <JWT Token>"

The server return error 500, with body:

{
  "error": "internal_server_error",
  "reason": "No DB shards could be opened.",
  "ref": ...
}

Expected Behaviour

The server should return 400 Bad Request.

Your Environment

Server: CouchDB/3.2.1 (Erlang OTP/23)

Running in Docker on Ubuntu 18.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions