Exit before filtering if no workers are listed (#3196)

This is just an early error message to avoid running the filtering
function if there are no workers to begin with.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2023-05-01 14:20:27 -04:00
1 parent af1092e8e8
commit c6d7dc01a0
1 file changed
+6
@@ -870,6 +870,12 @@ func (s Service) AuthorizeSession(ctx context.Context, req *pbs.AuthorizeSession
return nil, err
}
if len(selectedWorkers) == 0 {
return nil, handlers.ApiErrorWithCodeAndMessage(
codes.FailedPrecondition,
"No workers are available to handle this session.")
}
selectedWorkers, err = AuthorizeSessionWorkerFilterFn(ctx, t, selectedWorkers, h, s.downstreams)
if err != nil {
return nil, err