Skip to content

Commit

Permalink
err cleanup (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
gertd authored Nov 1, 2023
1 parent b7e32f8 commit c71fc98
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/app/auth/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func parseAuthHeader(val, expectedScheme string) (string, error) {
return "", aerr.ErrAuthenticationFailed.Msg("Bad authorization string")
}
if !strings.EqualFold(splits[0], expectedScheme) {
return "", aerr.ErrAuthenticationFailed.Str("expected-scheme", expectedScheme).Msg("Request unauthenticated with expected scheme")
return "", aerr.ErrAuthenticationFailed.Msgf("Request unauthenticated with expected scheme, expected: %s", expectedScheme)
}
return splits[1], nil
}
12 changes: 6 additions & 6 deletions pkg/app/impl/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ func (s *AuthorizerServer) DecisionTree(ctx context.Context, req *authorizer.Dec
).PrepareForEval(ctx)

if err != nil {
return resp, aerr.ErrBadQuery.Err(err).Str("query", queryStmt.String())
return resp, aerr.ErrBadQuery.Err(err).Msg(queryStmt.String())
}

queryResults, err := qry.Eval(ctx, rego.EvalInput(input))
if err != nil {
return resp, aerr.ErrBadQuery.Err(err).Str("query", queryStmt.String()).Msg("query evaluation failed")
return resp, aerr.ErrBadQuery.Err(err).Msgf("query evaluation failed: %s", queryStmt.String())
} else if len(queryResults) == 0 {
return resp, aerr.ErrBadQuery.Err(err).Str("query", queryStmt.String()).Msg("undefined results")
return resp, aerr.ErrBadQuery.Err(err).Msgf("undefined results: %s", queryStmt.String())
}

for _, expression := range queryResults[0].Expressions {
Expand Down Expand Up @@ -257,15 +257,15 @@ func (s *AuthorizerServer) Is(ctx context.Context, req *authorizer.IsRequest) (*
).PrepareForEval(ctx)

if err != nil {
return resp, aerr.ErrBadQuery.Err(err).Str("query", queryStmt)
return resp, aerr.ErrBadQuery.Err(err).Msg(queryStmt)
}

results, err := query.Eval(ctx, rego.EvalInput(input))

if err != nil {
return resp, aerr.ErrBadQuery.Err(err).Str("query", queryStmt).Msg("query evaluation failed")
return resp, aerr.ErrBadQuery.Err(err).Msgf("query evaluation failed: %s", queryStmt)
} else if len(results) == 0 {
return resp, aerr.ErrBadQuery.Err(err).Str("query", queryStmt).Msg("undefined results")
return resp, aerr.ErrBadQuery.Err(err).Msgf("undefined results: %s", queryStmt)
}

v := results[0].Bindings["x"]
Expand Down

0 comments on commit c71fc98

Please sign in to comment.