Skip to content

Commit

Permalink
fix: do not panic if an error occurs making a call (#2047)
Browse files Browse the repository at this point in the history
fixes #2045
Do not access `response.Msg` if `response` may be `nil` because we have
an error
  • Loading branch information
matt2e authored Jul 11, 2024
1 parent ff9a968 commit d41616f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1000,9 +1000,10 @@ func (s *Service) callWithRequest(
headers.AddCaller(req.Header(), schema.RefFromProto(req.Msg.Verb))

response, err := client.verb.Call(ctx, req)
resp := connect.NewResponse(response.Msg)
var resp *connect.Response[ftlv1.CallResponse]
var maybeResponse optional.Option[*ftlv1.CallResponse]
if resp != nil {
if err == nil {
resp = connect.NewResponse(response.Msg)
maybeResponse = optional.Some(resp.Msg)
}
s.recordCall(ctx, &Call{
Expand Down

0 comments on commit d41616f

Please sign in to comment.