Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router returns silent error if subgraph response is invalid format #6256

Open
smyrick opened this issue Nov 12, 2024 · 0 comments
Open

Router returns silent error if subgraph response is invalid format #6256

smyrick opened this issue Nov 12, 2024 · 0 comments

Comments

@smyrick
Copy link
Member

smyrick commented Nov 12, 2024

Describe the bug

A subgraph library should be adhering to the GraphQL Spec when returning a response with data, errors, and extensions. However, if for some reason a subgraph returns an valid response the Router does not log or emit any info that this happened.

This kinda happens for invalid data. If a subgraph returns something bad about a data block the Router doesn't log anything to console but it does atleast change the GraphQL response to an error like so, like calling it foo instead of data

{
  "message": "service 'users' response was malformed: graphql response without data must contain at least one error",
  "path": [],
  "extensions": {
    "service": "users",
    "reason": "graphql response without data must contain at least one error",
    "code": "SUBREQUEST_MALFORMED_RESPONSE"
  }
}

If the subgraph however returns a malformed GraphQL error in the errors array this fails with no logs and there is nothing in the Router response indicating that

eg if the path was incorrect then the Router just returns the data block and no errors at all

{
  "errors": [
    {
      "message": "can't fetch points for user user:1",
      "locations": [
        {
          "line": 1,
          "column": 14
        }
      ],
      "path": [
        "", // invalid text path here
        0,
        "loyaltyPoints"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      }
    }
  ]
}

To Reproduce

  • Start the router with the following config
include_subgraph_errors:
  all: true
  • Return a subgraph response with an invalid error

Expected behavior

At a minimum we should see Router logs but also probably something about a parsing or validation errors for clients to see as well

Desktop (please complete the following information):

  • OS: macOS
  • Version 14.7.1
  • Router 1.57.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant