From 8760dffb15b1a53937c9794f287f1cd0ffb8e7e2 Mon Sep 17 00:00:00 2001 From: Mitar Date: Tue, 16 Nov 2021 03:40:18 -0800 Subject: [PATCH] fix: fixed error handling in persister --- persistence/sql/persister_oauth2.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/persistence/sql/persister_oauth2.go b/persistence/sql/persister_oauth2.go index 1a1803597a8..c576733c708 100644 --- a/persistence/sql/persister_oauth2.go +++ b/persistence/sql/persister_oauth2.go @@ -378,7 +378,9 @@ func (p *Persister) FlushInactiveAccessTokens(ctx context.Context, notAfter time notAfter, ) if err := q.All(&signatures); err == sql.ErrNoRows { - return errors.Wrap(fosite.ErrNotFound, "") + return errorsx.WithStack(fosite.ErrNotFound) + } else if err != nil { + return errorsx.WithStack(err) } // Delete tokens in batch @@ -394,6 +396,9 @@ func (p *Persister) FlushInactiveAccessTokens(ctx context.Context, notAfter time fmt.Sprintf("DELETE FROM %s WHERE signature in (?)", OAuth2RequestSQL{Table: sqlTableAccess}.TableName()), signatures[i:j], ).Exec() + if err != nil { + break + } } } return sqlcon.HandleError(err) @@ -416,7 +421,9 @@ func (p *Persister) FlushInactiveRefreshTokens(ctx context.Context, notAfter tim notAfter, ) if err := q.All(&signatures); err == sql.ErrNoRows { - return errors.Wrap(fosite.ErrNotFound, "") + return errorsx.WithStack(fosite.ErrNotFound) + } else if err != nil { + return errorsx.WithStack(err) } // Delete tokens in batch @@ -432,6 +439,9 @@ func (p *Persister) FlushInactiveRefreshTokens(ctx context.Context, notAfter tim fmt.Sprintf("DELETE FROM %s WHERE signature in (?)", OAuth2RequestSQL{Table: sqlTableRefresh}.TableName()), signatures[i:j], ).Exec() + if err != nil { + break + } } } return sqlcon.HandleError(err)