Skip to content

Unexpected Error with GraphQL Query When Using Service Dataloader #3662

@mastercactapus

Description

@mastercactapus

Describe the Bug:
The application throws an "unexpected error" 500 response when a GraphQL query document uses the same variable name for multiple operations in the context of the GraphQL API key feature. This happens even if the operation is valid and works correctly with a user session. A workaround involves using unique variable names for each operation.

Steps to Reproduce:

  1. Create an API key with the following query:
query ServiceInfo($id: ID!) {
  service(id: $id) {
    id
    name
  }
}

query ServiceInfo2($id: ID!) {
  service(id: $id) {
    id
    name
  }
}
  1. Issue a request with curl:
curl -XPOST localhost:3030/api/graphql --data '{"variables":{"id":"72a85097-3601-43fe-a247-c0ee978333fd"},"operationName":"ServiceInfo"}' -H 'Content-Type: application/json' -H "Authorization: Bearer $API_KEY_TOKEN"
  1. Observe the response and the logs.

Expected Behavior:
Given that this is a valid GraphQL operation (which works correctly with a user session) the application should respond with service information.

Observed Behavior:
The application responds with a 500 error: {"errors":[{"message":"unexpected error","path":["service"]}],"data":{"service":null}} and logs an error: input: service ERROR: invalid input syntax for type uuid: \"\" (SQLSTATE 22P02)

Application Version:
This occurs on the latest version (master) of GoAlert while running the gql-api-keys experimental flag (make start EXPERIMENTAL=gql-api-keys)

Additional Context:
This is an API issue; OS, browser and device details aren't applicable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions