[#XX] tree: Wrap only ChainRouterError erros with ObjectAccessDenied
Some checks failed
Vulncheck / Vulncheck (pull_request) Successful in 2m59s
Pre-commit hooks / Pre-commit (pull_request) Successful in 4m12s
Tests and linters / gopls check (pull_request) Successful in 5m59s
Tests and linters / Run gofumpt (pull_request) Successful in 8m12s
Tests and linters / Tests with -race (pull_request) Successful in 8m19s
DCO action / DCO (pull_request) Failing after 8m39s
Build / Build Components (pull_request) Successful in 10m3s
Tests and linters / Staticcheck (pull_request) Successful in 10m28s
Tests and linters / Tests (pull_request) Successful in 10m47s
Tests and linters / Lint (pull_request) Successful in 11m18s

* 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 6849341d21
commit 4ead7084a9

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"
@ -64,12 +65,16 @@ func (s *Service) verifyClient(ctx context.Context, req message, cid cidSDK.ID,
}
if err = s.checkAPE(ctx, bt, cnr, cid, op, role, pubKey); err != nil {
return apeErr(err)
return processAPECheckErr(err)
}
return nil
}
func apeErr(err error) error {
func processAPECheckErr(err error) error {
var chRouterErr *checkercore.ChainRouterError
if !errors.As(err, &chRouterErr) {
return err
}
errAccessDenied := &apistatus.ObjectAccessDenied{}
errAccessDenied.WriteReason(err.Error())
return errAccessDenied