StPfeffer / rusty-roads

A simple route manager application written in Rust
MIT License
0 stars 0 forks source link

Bug Report: Incorrect Error Messages Returned to API #88

Closed StPfeffer closed 3 weeks ago

StPfeffer commented 3 weeks ago

Description

Currently, the API is returning incorrect error messages in response to certain requests. This issue requires validation and adjustments to ensure accurate error reporting aligns with the expected behavior.

Steps to Reproduce

Problem 1: Incorrect Error Message for Invalid statusId or vehicleId

  1. Make a POST request to /api/v1/routes/status with a invalid statusId or vehicleId.
  2. It returns an error message related to city not found, intead of a proper message to each field.

Problem 2: Inconsistent Error Message for Non-existent routeId

  1. Make a GET request to /api/v1/routes/:routeId/status with a routeId that is a valid UUID, but does not exists in the database.
  2. It returns an error message related to routenot found, instead of a route status not found.

Problem 3: Misleading Error Message for Non-existent statusId

  1. Make a DELETE request to /api/v1/routes/status/:statusId with a statusId that is a valid UUID, but does not exists in the database.
  2. It returns an error message related to route status not found, instead of a route not found.

Problem 4: Lack of Error Message for Non-existent collaboratorId

  1. Make a GET request to /api/v1/collaborators/:collaboratorId with a collaboratorId that is a valid UUID, but does not exists in the database.
  2. It does not returns a proper error message and hint.

Problem 5: Incorrect Error Message for Existing emailor cpf

  1. Make a POST request to /api/v1/collaborators with a email or cpf that already exists in the database.
  2. It returns an error message related to state already exists, instead of a collaborator already exists.

Problem 6: Lack of Error Message for Non-existent collaboratorId in DELETE Request

  1. Make a DELETE request to /api/v1/collaborators/:collaboratorId with a collaboratorId that is a valid UUID, but does not exists in the database.
  2. It does not returns a proper error message and hint.

Expected Behavior

The API should return error messages that accurately reflect the nature of the issue encountered during the request.

Actual Behavior

Incorrect error messages are returned, which do not provide useful information for debugging or resolving the issue.

Additional Information

This issue significantly impacts the reliability of error reporting. The incorrect error messages not only impede effective troubleshooting but also degrade the overall user experience by obscuring the root causes of issues.

Proposed Solution: Implement robust validation checks to ensure that error messages accurately correspond to the encountered scenarios. Additionally, revise the error handling logic to deliver clear and informative messages that assist users and developers in swiftly identifying and resolving problems.

Environment