From 1730c8a690ee4f99cb81deb3329b3a8859723cf7 Mon Sep 17 00:00:00 2001 From: Nathaniel Caza Date: Tue, 3 Nov 2020 09:17:58 -0600 Subject: [PATCH 1/2] return nil when a user override cannot be found --- override/store.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/override/store.go b/override/store.go index bae3fe05cf..8360103ec2 100644 --- a/override/store.go +++ b/override/store.go @@ -3,13 +3,15 @@ package override import ( "context" "database/sql" + "errors" + "time" + "github.com/target/goalert/assignment" "github.com/target/goalert/permission" "github.com/target/goalert/util" "github.com/target/goalert/util/sqlutil" "github.com/target/goalert/validation" "github.com/target/goalert/validation/validate" - "time" uuid "github.com/satori/go.uuid" ) @@ -129,6 +131,9 @@ func (db *DB) FindOneUserOverrideTx(ctx context.Context, tx *sql.Tx, id string, var o UserOverride var add, rem, schedTgt sql.NullString err = stmt.QueryRowContext(ctx, id).Scan(&o.ID, &add, &rem, &o.Start, &o.End, &schedTgt) + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } if err != nil { return nil, err } From 31a8bb7752a028c408c8c96b4238e001197265a5 Mon Sep 17 00:00:00 2001 From: Nathaniel Caza Date: Tue, 3 Nov 2020 09:31:00 -0600 Subject: [PATCH 2/2] log error before overwriting message --- graphql2/graphqlapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphql2/graphqlapp/app.go b/graphql2/graphqlapp/app.go index 1189bb4c27..7b17168662 100644 --- a/graphql2/graphqlapp/app.go +++ b/graphql2/graphqlapp/app.go @@ -198,8 +198,8 @@ func (a *App) Handler() http.Handler { } if isUnsafe && !isGQLValidation(gqlErr) { - gqlErr.Message = safeErr.Error() log.Log(ctx, err) + gqlErr.Message = safeErr.Error() } var multiFieldErr validation.MultiFieldError