Incorrect HTTP error statuses #191

Open
opened 2024-12-28 13:37:45 +00:00 by r.loginov · 0 comments
Member

At the moment, we have an incorrect status code or message in several places in case of an error.

Expected Behavior

  • If an ErrAccessDenied error occurs, the status 403 Forbidden is returned to the user.
  • If an ErrGatewayTimeout error occurs, the status 504 Gateway Timeout is returned to the user.
  • If an ErrNodeAccessDenied error occurs, the status 403 Forbidden is returned to the user.
  • If an ErrNotFound error occurs, the user is returned 404 Not Found.
  • The error text always contains the correct information.
  • API documentation in the file api.md fully compliant with the current API.

Current Behavior

The problems that I managed to find:

  • The error ErrAccessDenied is not processed. If this error occurs, we return the status 400 Bad Request.
  • The ErrGatewayTimeout error is not being processed.
  • The ErrNodeAccessDenied error is not being processed
  • The ErrNotFound error is not processed (We don't expect it from frostfs storage at all.).
  • There is a place where handleBucketError is called at the place where we process the oid parameter and, in case of an error, call the error handler for bucket operations. As a result, we see the phrase "could not get bucket" in the error message.
  • The API documentation has the status 500 Internal Server Error, although we never return it.

As part of this task, you should:

  1. Fix all the above problems.
  2. Check that the error handling from frostfs and from the tree service is correct and all errors defined for these layers are handled.
  3. Check that the error messages contain the correct information.
  4. If new error handling functions appear, cover them with tests.
  5. Update the documentation api.md up to the current state.
At the moment, we have an incorrect status code or message in several places in case of an error. ## Expected Behavior - If an [ErrAccessDenied](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/internal/handler/handler.go#L140) error occurs, the status 403 Forbidden is returned to the user. - If an [ErrGatewayTimeout](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/internal/handler/handler.go#L142) error occurs, the status 504 Gateway Timeout is returned to the user. - If an [ErrNodeAccessDenied](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/internal/layer/tree_service.go#L23) error occurs, the status 403 Forbidden is returned to the user. - If an ErrNotFound error occurs, the user is returned 404 Not Found. - The error text always contains the correct information. - API documentation in the file [api.md](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/docs/api.md) fully compliant with the current API. ## Current Behavior The problems that I managed to find: - The error [ErrAccessDenied](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/internal/handler/handler.go#L140) is not processed. If this error occurs, we return the status 400 Bad Request. - The [ErrGatewayTimeout](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/internal/handler/handler.go#L142) error is not being processed. - The [ErrNodeAccessDenied](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/internal/layer/tree_service.go#L23) error is not being processed - The ErrNotFound error is not processed (We don't expect it from frostfs storage at all.). - There is a [place](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/internal/handler/handler.go#L387) where handleBucketError is called at the place where we process the oid parameter and, in case of an error, call the error handler for bucket operations. As a result, we see the phrase "could not get bucket" in the error message. - The API documentation has the status 500 Internal Server Error, although we never return it. As part of this task, you should: 1. Fix all the above problems. 2. Check that the error handling from frostfs and from the tree service is correct and all errors defined for these layers are handled. 3. Check that the error messages contain the correct information. 4. If new error handling functions appear, cover them with tests. 5. Update the documentation [api.md](https://git.frostfs.info/TrueCloudLab/frostfs-http-gw/src/branch/master/docs/api.md) up to the current state.
r.loginov added the
bug
label 2024-12-28 13:37:45 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-http-gw#191
No description provided.