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

BUG: Incorrect Error Response for Invalid Route #221

Open
DaniellaZambrano opened this issue Sep 9, 2024 · 1 comment · Fixed by #248
Open

BUG: Incorrect Error Response for Invalid Route #221

DaniellaZambrano opened this issue Sep 9, 2024 · 1 comment · Fixed by #248
Assignees
Labels
BE Backend feature BUG Something isn't working
Milestone

Comments

@DaniellaZambrano
Copy link
Collaborator

DaniellaZambrano commented Sep 9, 2024

Describe your issue

When making a request in Postman with an incorrectly written route, the system returns a 401 Unauthorized error instead of an appropriate error indicating that the route is not found. The 401 error suggests an authentication issue, which is misleading when the actual issue is a miswritten route.

Steps to reproduce

  1. Open Postman.
  2. Enter an invalid or incorrectly written route in the request URL field (e.g., /signup).
    2. The correct one is /sign-up
  3. Set the request method to the appropriate type (GET, POST, etc.) in this case is POST.
  4. Send the request.

What was the actual result?

401:

{
"errorType": "COMMON",
"message": "Token is no longer valid. Please log in again."
}

What was the expected result?

The server should return a 404 Not Found error indicating that the route is not available or incorrectly specified.

Put here any screenshots or videos (optional)

Image

What OS are you seeing the problem on?

Other (mention in the description)

What browsers are you seeing the problem on?

Other (mention in the description)

Severity

Trivial (S5)

@DaniellaZambrano DaniellaZambrano added BE Backend feature BUG Something isn't working labels Sep 9, 2024
@DaniellaZambrano DaniellaZambrano self-assigned this Sep 9, 2024
@DaniellaZambrano DaniellaZambrano added QA QA tasks and removed QA QA tasks labels Sep 10, 2024
@DaniellaZambrano DaniellaZambrano removed their assignment Sep 10, 2024
@DaniellaZambrano DaniellaZambrano added this to the Pre-DEMO Release milestone Sep 10, 2024
@lfelix3011 lfelix3011 self-assigned this Sep 10, 2024
@lfelix3011 lfelix3011 moved this from Todo to In Progress in bsa-2024-outreachvids Sep 10, 2024
@lfelix3011 lfelix3011 linked a pull request Sep 11, 2024 that will close this issue
@lfelix3011 lfelix3011 moved this from In Progress to Peer Review in bsa-2024-outreachvids Sep 11, 2024
@github-project-automation github-project-automation bot moved this from Peer Review to To Be Tested in bsa-2024-outreachvids Sep 11, 2024
@DaniellaZambrano DaniellaZambrano self-assigned this Sep 11, 2024
@nikita-remeslov nikita-remeslov moved this from To Be Tested to In Progress in bsa-2024-outreachvids Sep 12, 2024
@lfelix3011
Copy link
Collaborator

This behavior occurs due to how Fastify validates requests. It first performs all validations (including token validation) before checking if the route exists. Since the token validation throws an error first, we get that error instead of the 404, which is handled by the setNotFoundHandler method.

The approach implemented was to retrieve all system routes, and if the route being accessed is not in the system or the whitelist, let the setNotFoundHandler handle it.

But to use printRoutes it need to be inside or after a this.app.ready(), but when trying to implement this other method we get the error "Root plugin has already booted".

@lfelix3011 lfelix3011 moved this from In Progress to Todo in bsa-2024-outreachvids Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE Backend feature BUG Something isn't working
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

4 participants