-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistent inner errors for validation errors #135
Comments
Great job, thanks for putting this together. A few questions,
My biggest worry, is breaking existing behaviour. |
I think we can do it backwards compatible in the following way:
One could even argue that we could change the error strings of Update: To add on that, we already did something similar to 3.) already in #97 The approach works without any new dependencies. |
Fixes #135 by implementing `Is(err) bool` for the `ValidationError`. It both checks for the actual inner error message as well as our error flags for maximum backwards compatibility
Fixes #135 by implementing `Is(err) bool` for the `ValidationError`. It both checks for the actual inner error message as well as our error flags for maximum backwards compatibility
Fixes #135 by implementing `Is(err) bool` for the `ValidationError`. It both checks for the actual inner error message as well as our error flags for maximum backwards compatibility
With PR #125 we can finally unwrap the
Inner
error of anValidationError
, for example to check for its underlying error, such as expiration or mis-formed token, e.g. usingerror.Is
However, we are not consistent in setting our inner errors. For example, for an expired map claim we set it to:
jwt/map_claims.go
Line 129 in c435f38
However, for our
RegisteredClaims
andStandardClaims
we are setting it to:jwt/claims.go
Line 59 in c435f38
In other cases we are actually using constant error strings, such as:
jwt/errors.go
Line 9 in 823c014
I would propose to harmonize this, possibly introducing an
ErrExpiredClaim
as a constant error string in this example to allow something likeWe could also potentially override
Is(err)
on validation error to check for the error using our flags rather than the error string.I know that there is already a PR #100 open, but it introduces a lot of other changes and seems to be stale.
The text was updated successfully, but these errors were encountered: