router icon indicating copy to clipboard operation
router copied to clipboard

Router Fails to Recognize content-type Header in Federated Service Responses Without Payloads

Open mostafao-spotify opened this issue 1 year ago • 1 comments

Describe the Bug

We are self-hosting the Router image on a Kubernetes cluster. Whenever a federated service returns a 4xx or 5xx status, the Router expects a payload in the response. If there is no payload, the Router does not recognize the content-type header in the response and returns the error: subgraph response does not contain 'content-type' header, even though the federated service response does include that header.

To Reproduce

Steps to reproduce the behavior:

  1. Create a federated service that defaults to returning a 500 status on any request, and include the "content-type", "application/json" header in the response.
  2. Submit a query through the Router to hit that federated service.
  3. Observe the error: HTTP fetch failed from 'some-federated-service': subgraph response does not contain 'content-type' header; expected content-type: application/json or content-type: application/graphql-response+json.

Expected Behavior

This error should not occur, as the content-type header is already present in the response.

Output

{
    "data": null,
    "errors": [
      {
        "message": "HTTP fetch failed from 'some-federated-service': 500: Internal Server Error",
        "extensions": {
          "code": "SUBREQUEST_HTTP_ERROR",
          "service": "some-federated-service",
          "reason": "500: Internal Server Error",
          "http": {
            "status": 500
          }
        }
      },
      {
        "message": "HTTP fetch failed from 'some-federated-service': subgraph response does not contain 'content-type' header; expected content-type: application/json or content-type: application/graphql-response+json",
        "extensions": {
          "code": "SUBREQUEST_HTTP_ERROR",
          "service": "some-federated-service",
          "reason": "subgraph response does not contain 'content-type' header; expected content-type: application/json or content-type: application/graphql-response+json",
          "http": {
            "status": 500
          }
        }
      }
    ]
  }

Router version:

  • Version v1.52.0

mostafao-spotify avatar Aug 13 '24 03:08 mostafao-spotify