Skip to content

Commit

Permalink
fix: Fix Header Duplication (#1568)
Browse files Browse the repository at this point in the history
When using connectrpc to perform calls, duplicate headers are introduced
if the response object is returned directly by the runner or the
controller. This causes bugs when FTL is deployed to an environment that
does not work when there are duplicate headers, such as an environment
where envoy is used to facilitate traffic.

The fix for this is to instantiate a new response object to return from
the Call functions.

For more information on the envoy bug, see the issue linked below. 
envoyproxy/envoy#9019

The fix for this took place after reaching out to the Buf team on slack
https://bufbuild.slack.com/archives/CRZ680FUH/p1716344335783839
  • Loading branch information
alec-brooks authored May 24, 2024
1 parent dc09486 commit 0bbfee0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,8 @@ func (s *Service) callWithRequest(
ctx = rpc.WithVerbs(ctx, append(callers, verbRef))
headers.AddCaller(req.Header(), schema.RefFromProto(req.Msg.Verb))

resp, err := client.verb.Call(ctx, req)
response, err := client.verb.Call(ctx, req)
resp := connect.NewResponse(response.Msg)
var maybeResponse optional.Option[*ftlv1.CallResponse]
if resp != nil {
maybeResponse = optional.Some(resp.Msg)
Expand Down
3 changes: 2 additions & 1 deletion backend/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ func (s *Service) Call(ctx context.Context, req *connect.Request[ftlv1.CallReque
if !ok {
return nil, connect.NewError(connect.CodeUnavailable, errors.New("no deployment"))
}
return deployment.plugin.Client.Call(ctx, req)
response, err := deployment.plugin.Client.Call(ctx, req)
return connect.NewResponse(response.Msg), err
}

func (s *Service) Reserve(ctx context.Context, c *connect.Request[ftlv1.ReserveRequest]) (*connect.Response[ftlv1.ReserveResponse], error) {
Expand Down

0 comments on commit 0bbfee0

Please sign in to comment.