[#1563] tree: Wrap only ChainRouterError erros with ObjectAccessDenied
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m37s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m25s
Tests and linters / gopls check (pull_request) Successful in 3m47s
DCO action / DCO (pull_request) Successful in 5m54s
Tests and linters / Tests with -race (pull_request) Successful in 6m34s
Vulncheck / Vulncheck (pull_request) Successful in 7m3s
Build / Build Components (pull_request) Successful in 7m39s
Tests and linters / Tests (pull_request) Successful in 7m57s
Tests and linters / Staticcheck (pull_request) Successful in 8m17s
Tests and linters / Lint (pull_request) Successful in 8m42s
Tests and linters / Run gofumpt (push) Successful in 1m24s
Tests and linters / Staticcheck (push) Successful in 3m24s
Tests and linters / Lint (push) Successful in 4m48s
Vulncheck / Vulncheck (push) Successful in 6m26s
Build / Build Components (push) Successful in 7m8s
Tests and linters / Tests (push) Successful in 7m19s
Pre-commit hooks / Pre-commit (push) Successful in 7m36s
Tests and linters / Tests with -race (push) Successful in 7m52s
Tests and linters / gopls check (push) Successful in 8m4s

* Such wrapping helps to differentiate logical check errors and server internal
  errors.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-12-16 14:17:37 +03:00
parent 1a091ea7bb
commit 6e82661c35

View file

@ -9,6 +9,7 @@ import (
"fmt"
core "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/container"
checkercore "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/common/ape"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/refs"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/bearer"
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
@ -70,6 +71,12 @@ func (s *Service) verifyClient(ctx context.Context, req message, cid cidSDK.ID,
}
func apeErr(err error) error {
var chRouterErr *checkercore.ChainRouterError
if !errors.As(err, &chRouterErr) {
errServerInternal := &apistatus.ServerInternal{}
apistatus.WriteInternalServerErr(errServerInternal, err)
return errServerInternal
}
errAccessDenied := &apistatus.ObjectAccessDenied{}
errAccessDenied.WriteReason(err.Error())
return errAccessDenied