diff --git a/errors.go b/errors.go index 09ac1d65..332dbec2 100644 --- a/errors.go +++ b/errors.go @@ -25,8 +25,12 @@ var ( ErrInvalidatedAuthorizeCode = stderr.New("Authorization code has ben invalidated") // ErrSerializationFailure is an error indicating that the transactional capable storage could not guarantee // consistency of Update & Delete operations on the same rows between multiple sessions. - ErrSerializationFailure = stderr.New("The request could not be completed due to concurrent access") - ErrUnknownRequest = &RFC6749Error{ + ErrSerializationFailure = &RFC6749Error{ + ErrorField: errUnknownErrorName, + DescriptionField: "The request could not be completed because another request is competing for the same resource.", + CodeField: http.StatusConflict, + } + ErrUnknownRequest = &RFC6749Error{ ErrorField: errUnknownErrorName, DescriptionField: "The handler is not responsible for this request.", CodeField: http.StatusBadRequest, diff --git a/handler/oauth2/flow_refresh.go b/handler/oauth2/flow_refresh.go index 5bf68070..789f8d63 100644 --- a/handler/oauth2/flow_refresh.go +++ b/handler/oauth2/flow_refresh.go @@ -221,12 +221,14 @@ func (c *RefreshTokenGrantHandler) handleRefreshTokenEndpointStorageError(ctx co if errors.Is(storageErr, fosite.ErrSerializationFailure) { return errorsx.WithStack(fosite.ErrInvalidRequest. WithDebugf(storageErr.Error()). + WithWrap(storageErr). WithHint("Failed to refresh token because of multiple concurrent requests using the same token which is not allowed.")) } if errors.Is(storageErr, fosite.ErrNotFound) || errors.Is(storageErr, fosite.ErrInactiveToken) { return errorsx.WithStack(fosite.ErrInvalidRequest. WithDebugf(storageErr.Error()). + WithWrap(storageErr). WithHint("Failed to refresh token because of multiple concurrent requests using the same token which is not allowed.")) }