Skip to content

Commit db74aa7

Browse files
authored
chore: make serialization error wrappable (#837)
See ory-corp/cloud#7311
1 parent 6335f90 commit db74aa7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

errors.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ var (
2525
ErrInvalidatedAuthorizeCode = stderr.New("Authorization code has ben invalidated")
2626
// ErrSerializationFailure is an error indicating that the transactional capable storage could not guarantee
2727
// consistency of Update & Delete operations on the same rows between multiple sessions.
28-
ErrSerializationFailure = stderr.New("The request could not be completed due to concurrent access")
29-
ErrUnknownRequest = &RFC6749Error{
28+
ErrSerializationFailure = &RFC6749Error{
29+
ErrorField: errUnknownErrorName,
30+
DescriptionField: "The request could not be completed because another request is competing for the same resource.",
31+
CodeField: http.StatusConflict,
32+
}
33+
ErrUnknownRequest = &RFC6749Error{
3034
ErrorField: errUnknownErrorName,
3135
DescriptionField: "The handler is not responsible for this request.",
3236
CodeField: http.StatusBadRequest,

handler/oauth2/flow_refresh.go

+2
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,14 @@ func (c *RefreshTokenGrantHandler) handleRefreshTokenEndpointStorageError(ctx co
221221
if errors.Is(storageErr, fosite.ErrSerializationFailure) {
222222
return errorsx.WithStack(fosite.ErrInvalidRequest.
223223
WithDebugf(storageErr.Error()).
224+
WithWrap(storageErr).
224225
WithHint("Failed to refresh token because of multiple concurrent requests using the same token which is not allowed."))
225226
}
226227

227228
if errors.Is(storageErr, fosite.ErrNotFound) || errors.Is(storageErr, fosite.ErrInactiveToken) {
228229
return errorsx.WithStack(fosite.ErrInvalidRequest.
229230
WithDebugf(storageErr.Error()).
231+
WithWrap(storageErr).
230232
WithHint("Failed to refresh token because of multiple concurrent requests using the same token which is not allowed."))
231233
}
232234

0 commit comments

Comments
 (0)