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

Not informative INTERNAL_SERVER_ERROR when mutation has invalid input as variable #2204

Closed
ph55 opened this issue Jan 21, 2019 · 5 comments
Closed

Comments

@ph55
Copy link

ph55 commented Jan 21, 2019

If mutation request made with input variable and it has invalid data - error not informative.
Example:

  • Good. Login mutation with regular input
mutation {
  login(input: {
    username: "user",
    password: 1
  })
}

Response:

{
  "errors": [
    {
      "message": "Expected type String!, found 1.",
      "locations": [
        {
          "line": 4,
          "column": 13
        }
      ],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED"
      }
    }
  ]
}

  • Bad. Login mutation with variable input
mutation login($input: LoginInput!) {
  login(input: $input)
}

variables:

{
  "input": {
    "username": "user",
    "password": 1
   }
}

Response:

{
  "errors": [
    {
      "message": "Internal server error",
      "locations": [
        {
          "line": 1,
          "column": 16
        }
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      }
    }
  ]
}

As you can see there is zero information regarding error. Also it should be GRAPHQL_VALIDATION_FAILED instead of INTERNAL_SERVER_ERROR.
Only if with debug on you can see the error:

{
  "errors": [
    {
      "message": "Internal server error",
      "locations": [
        {
          "line": 1,
          "column": 16
        }
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: String cannot represent a non string value: 0",
            "........."
          ]
        }
      }
    }
  ]
}

Probably related to #1410
Still opening this one since it have a bit more information.

This is a big issue since normal API couldn't be built without error info.

@ph55 ph55 closed this as completed Jan 21, 2019
@kfrajtak
Copy link

I am afraid this does not work in 2.6.7.

@glasser
Copy link
Member

glasser commented Apr 6, 2021

Duplicate of #3498

@glasser glasser marked this as a duplicate of #3498 Apr 6, 2021
@glasser
Copy link
Member

glasser commented Apr 9, 2021

I've released a prerelease with this fix, version 2.23.0-alpha.0. Try out the alpha and see if it works for you! Please provide any feedback in #5094.

@glasser
Copy link
Member

glasser commented Apr 9, 2021

(as a workaround you can also switch your setup to using payloadFormatVersion 1.0)

@glasser
Copy link
Member

glasser commented Apr 14, 2021

This is released in Apollo Server 2.23.0.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants