Skip to content

Commit 23a7166

Browse files
committed
[core] Better handling of invalid incoming transition request
1 parent 4de111b commit 23a7166

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

core/server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,12 @@ func (m *RpcServer) ControlEnvironment(cxt context.Context, req *pb.ControlEnvir
286286
return nil, status.Newf(codes.NotFound, "environment not found: %s", err.Error()).Err()
287287
}
288288

289-
err = env.TryTransition(environment.MakeTransition(m.state.taskman, req.Type))
289+
trans := environment.MakeTransition(m.state.taskman, req.Type)
290+
if trans == nil {
291+
return nil, status.Newf(codes.InvalidArgument, "cannot prepare invalid transition %s", req.GetType().String()).Err()
292+
}
293+
294+
err = env.TryTransition(trans)
290295

291296
reply := &pb.ControlEnvironmentReply{
292297
Id: env.Id().String(),

0 commit comments

Comments
 (0)