Skip to content

Commit

Permalink
[core] Better handling of invalid incoming transition request
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Apr 29, 2019
1 parent 4de111b commit 23a7166
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,12 @@ func (m *RpcServer) ControlEnvironment(cxt context.Context, req *pb.ControlEnvir
return nil, status.Newf(codes.NotFound, "environment not found: %s", err.Error()).Err()
}

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

err = env.TryTransition(trans)

reply := &pb.ControlEnvironmentReply{
Id: env.Id().String(),
Expand Down

0 comments on commit 23a7166

Please sign in to comment.