Skip to content

When FAST_JWT_MISSING_REQUIRED_CLAIM is thrown, a 500 is returned and not a 401 #368

@frederikprijck

Description

@frederikprijck

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.2.1

Plugin version

9.0.4

Node.js version

20

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

15.3

Description

When fast-jwt throws a FAST_JWT_MISSING_REQUIRED_CLAIM here, it isn't beind mapped to a known error in jastify-jwt, resulting in a 500 instead of a 401.

{
  "code": "FAST_JWT_MISSING_REQUIRED_CLAIM",
  "error": "Internal Server Error",
  "message": "The iss claim is required.",
  "statusCode": 500,
}

Is this expected, or would it make more sense to ensure this also results in a 401?

Link to code that reproduces the bug

N/A

Expected Behavior

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions