Potential confusion about apistatus
error types' semantic equivalence #481
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#481
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Consider the following (failing) test:
The failure is due to the implementation of container.IsErrNotFound:
In general, this can give rise to some very subtle hard-to-track bugs when using pointers or structs, since we often act on error types. For example, it could cause objects to not be buried (inhumed) silently by the policer: https://git.frostfs.info/TrueCloudLab/frostfs-node/src/branch/master/pkg/services/policer/check.go#L81.
We should do something about this to save ourselves from future pain.
I suppose we've already got a bug
Here is ObjectAccessDenided status check within
Range
remote procedure call. The reason has not been discovered yet but the problem is thaterrors.As
never works with apistatus error.This leads to incorrect behavior and unexpected error
can we make all
apistatus
error receivers pointers and useerrors.Is
instead? this would avoid the issue altogether at compile time:EDIT: although that doesn't work when errors are not actually equal. So perhaps the solution is just implementing
Is
for each error. Kinda annoying.I think it's easier to export wrapsErrType and use that everywhere.
The alternatives I see are:
IsErrX
for every error type X.Is
must handle the case where the error contains error-specific data and so it's not pure equality.Think
wrapsErrType
and (2) are not mutually exclusive, both are ok. The only thing I don't like aboutwrapsErrType
is generic errors checking function being exported from the SDK package -- we already haveerrors.Is
, it may be more appropriate here.Another option is to have a single type for status errors and
status.Code
extractor, like for gRPC. It wont fork with multi-wrapped errors, but it doesn't seem a problem.ok. The original bug is not more, so I'm closing. We can address the design question elsewhere.