ape: Improve error messages in ape service #919

Merged
fyrchik merged 1 commit from aarifullin/frostfs-node:feature/ape_errors into master 2024-01-23 08:11:26 +00:00
Member
  • Wrap all APE middleware errors in apeErr that
    makes errors more explicit with status AccessDenied.
  • Use denyingRuleErr for denying status from chain router.
* Wrap all APE middleware errors in apeErr that makes errors more explicit with status AccessDenied. * Use denyingRuleErr for denying status from chain router.
aarifullin requested review from storage-core-committers 2024-01-18 11:40:05 +00:00
aarifullin requested review from storage-core-developers 2024-01-18 11:40:38 +00:00
fyrchik approved these changes 2024-01-18 14:38:55 +00:00
@ -0,0 +7,4 @@
"git.frostfs.info/TrueCloudLab/policy-engine/pkg/chain"
)
func apeErr(err error) error {
Owner

Minor sugession: APE err is actually an argument, what we do here is add API status, how about toStatus() or wrapStatus or at least toStatusErr?

Minor sugession: APE err is actually an argument, what we do here is add API status, how about `toStatus()` or `wrapStatus` or at least `toStatusErr`?
@ -0,0 +13,4 @@
return errAccessDenied
}
type denyingRuleErr struct {
Owner

The only thing we do with this type is translate it to string in apeErr anyway, why do we need it? We do not use %w, so we might as well have old wrapper and a new one. This way we won't have 2 fmt.Sprintf.

The only thing we do with this type is translate it to string in `apeErr` anyway, why do we need it? We do not use `%w`, so we might as well have old wrapper and a new one. This way we won't have 2 `fmt.Sprintf`.
Author
Member

Initally that was for unit-test sake: I want a test to expect only this kind of error (with require.ErrorAs) but I think you're right - this does not make a big deal. I removed it and apeErr -> toStatusErr

Initally that was for unit-test sake: I want a test to expect only this kind of error (with `require.ErrorAs`) but I think you're right - this does not make a big deal. I removed it and `apeErr` -> `toStatusErr`
@ -0,0 +28,4 @@
}
func (d *denyingRuleErr) Error() string {
return fmt.Sprintf("found denying rule for %s: %s", d.method, d.status.String())
Owner

WIth .String() invocation is done automatically for %s.

WIth `.String()` invocation is done automatically for `%s`.
Author
Member

You're right - I've forgotten about standard Stringer interface

You're right - I've forgotten about standard Stringer interface
Owner

@aarifullin There is still XX in the commit header

@aarifullin There is still XX in the commit header
aarifullin force-pushed feature/ape_errors from a9bc688233 to 79a9631c72 2024-01-19 08:01:41 +00:00 Compare
aarifullin force-pushed feature/ape_errors from 79a9631c72 to 19937c67f8 2024-01-19 08:04:09 +00:00 Compare
Author
Member

@aarifullin There is still XX in the commit header

Fixed

> @aarifullin There is still XX in the commit header Fixed
aarifullin requested review from fyrchik 2024-01-19 08:04:24 +00:00
acid-ant approved these changes 2024-01-23 08:04:29 +00:00
fyrchik approved these changes 2024-01-23 08:11:12 +00:00
fyrchik merged commit f2f3294fc3 into master 2024-01-23 08:11:26 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-core-developers
No milestone
No project
No assignees
3 participants
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-node#919
No description provided.