Skip to content

Commit

Permalink
pass input to log even if checkrequest times out
Browse files Browse the repository at this point in the history
  • Loading branch information
rudrakhp committed Oct 24, 2023
1 parent 064d640 commit 1af6ac8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,6 @@ func (p *envoyExtAuthzGrpcServer) check(ctx context.Context, req interface{}) (*
return nil
}

if ctx.Err() != nil {
err = errors.Wrap(ctx.Err(), "check request timed out before query execution")
return nil, stop, err
}

input, err = envoyauth.RequestToInput(req, logger, p.cfg.protoSet, p.cfg.SkipRequestBodyParse)
if err != nil {
return nil, stop, err
Expand All @@ -400,6 +395,11 @@ func (p *envoyExtAuthzGrpcServer) check(ctx context.Context, req interface{}) (*
return nil, stop, err
}

if ctx.Err() != nil {
err = errors.Wrap(ctx.Err(), "check request timed out before query execution")
return nil, stop, err
}

if err = envoyauth.Eval(ctx, p, inputValue, result); err != nil {
evalErr = err
return nil, stop, err
Expand Down
4 changes: 4 additions & 0 deletions internal/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,10 @@ func TestCheckContextTimeout(t *testing.T) {
if event.Error.Error() != expectedErrMsg {
t.Fatalf("Expected error message %v but got %v", expectedErrMsg, event.Error.Error())
}

if len((*event.Input).(map[string]interface{})) == 0 {
t.Fatalf("Expected non empty input but got %v", *event.Input)
}
}

func TestCheckIllegalDecisionWithLogger(t *testing.T) {
Expand Down

0 comments on commit 1af6ac8

Please sign in to comment.