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

Upgrade from 2.2.0 to 2.3.0 breaks app (GraphQL queries with fragments) #3874

Closed
nesrual opened this issue Aug 29, 2024 · 7 comments · Fixed by #3887
Closed

Upgrade from 2.2.0 to 2.3.0 breaks app (GraphQL queries with fragments) #3874

nesrual opened this issue Aug 29, 2024 · 7 comments · Fixed by #3887
Assignees
Labels
appsec Application Security monitoring product bug Involves a bug community Was opened by a community member
Milestone

Comments

@nesrual
Copy link

nesrual commented Aug 29, 2024

Current behaviour
Logging works as expected with 2.2.0

Expected behaviour
The app crashes with this error message:

undefined method `arguments' for an instance of GraphQL::Language::Nodes::FragmentSpread (NoMethodError)

                  set_hash_with_variables(resolver_args, selection.arguments, query.provided_variables)
                                                                  ^^^^^^^^^^

This is when GraphQL queries are performed:

result = DaBackendSchema.execute(query, variables:, context:, operation_name:)
Crashed in non-app: datadog (2.3.0) lib/datadog/appsec/contrib/graphql/gateway/multiplex.rb in block in create_arguments_hash
@nesrual nesrual added bug Involves a bug community Was opened by a community member labels Aug 29, 2024
@y9v
Copy link
Member

y9v commented Aug 29, 2024

hey @nesrual, thank you for reaching out!

I will look into this.

@y9v y9v self-assigned this Aug 29, 2024
@y9v y9v added the appsec Application Security monitoring product label Aug 29, 2024
@y9v
Copy link
Member

y9v commented Aug 29, 2024

@nesrual could you tell me your graphql gem version, and maybe also something about how I can reproduce this issue?

Is this some particular query that is failing?

@nesrual
Copy link
Author

nesrual commented Aug 29, 2024

It seems to be all queries. I have not been able to reproduce the error in test/dev yet. I will test further tomorrow and let you know my findings.

We use the following GraphQL gems:

graphql-pro (1.29.0)
graphql (2.3.14)
      base64
      fiber-storage
    graphql-batch (0.6.0)
      graphql (>= 1.12.18, < 3)
      promise.rb (~> 0.7.2)
    graphql-c_parser (1.1.1)
      graphql (>= 2.2.10)
    graphql-persisted_queries (1.8.1)
      graphql (>= 1.12)

@nesrual
Copy link
Author

nesrual commented Aug 30, 2024

I have done some more digging around and I found that this triggers the error:

This query will result in a 500 server error:

query {
  accounts {
    ...AccountDetails
    __typename
  }
}

fragment AccountDetails on Account {
  id
  name
  accountType
  useBudget
  parent {
    id
    __typename
  }
  __typename
}

whereas this works fine:

query {
  accounts {
  id
  name
  accountType
  useBudget
  parent {
    id
    __typename
  }
    __typename
  }
}

So I think it could have something to do with using fragments in the query.

The error returned is:

web-1  | App 321 output: NoMethodError (undefined method `arguments' for an instance of GraphQL::Language::Nodes::FragmentSpread):
web-1  | App 321 output:
web-1  | App 321 output: app/controllers/graphql_controller.rb:25:in `execute'
web-1  | App 321 output:
web-1  | App 321 output: NoMethodError (undefined method `arguments' for an instance of GraphQL::Language::Nodes::FragmentSpread):
web-1  | App 321 output:
web-1  | App 321 output: app/controllers/graphql_controller.rb:25:in `execute'

@y9v
Copy link
Member

y9v commented Aug 30, 2024

@nesrual thank you! This definitely helps a lot, I will look into queries with fragments

@y9v
Copy link
Member

y9v commented Aug 30, 2024

@nesrual I could reproduce the issue locally and I am now actively working on a fix for this

@nesrual nesrual changed the title Upgrade from 2.2.0 to 2.3.0 breaks app Upgrade from 2.2.0 to 2.3.0 breaks app (GraphQL queries with fragments) Aug 30, 2024
@y9v y9v closed this as completed in #3887 Sep 11, 2024
@y9v
Copy link
Member

y9v commented Oct 11, 2024

@nesrual we just released version 2.4.0 that fixes this issue. Could you please try it out?

@ivoanjo ivoanjo added this to the 2.4.0 milestone Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appsec Application Security monitoring product bug Involves a bug community Was opened by a community member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants