dgs-framework icon indicating copy to clipboard operation
dgs-framework copied to clipboard

bug: Some invalid queries get exposed as "unknown" or "Intenal" instead of "ValidationError" or "BadRequest" in micrometer

Open hpuac opened this issue 3 years ago • 6 comments

Expected behavior

When modifying the GraphQL request and sending a variable that is not in the query, I would expect it to get exposed as ValidationError or BAD_REQUEST in micrometer.

Actual behavior

  • When modifying the GraphQL request and sending a variable that is not in the query, it gets exposed as errorType unknown in micrometer.
  • When modifying a federated GraphQL request and sending a variable that is not in the query, it gets exposed as errorTyoe INTERNAL in micrometer.

This is preventing me to exclude client errors from our alerting that we base on these metrics.

Steps to reproduce

I think the behaviour description is pretty self explanatory. Please let me know if something is not clear. But I'd like to provide some additional information.

  • When the error type "unknown" is exposed, the exception that DgsGraphQLMetricsInstrumentation->instrumentExecutionResult receives is graphql.execution.InputMapDefinesTooManyFieldsException: The variables input contains a field name 'myDemoKey' that is not defined for input object type 'MyDemoInput' . The ErrorUtils.sanitizeErrorPaths() call then sets the type to unknown.
  • When the error type INTERNAL is exposed, the exception that DgsGraphQLMetricsInstrumentation->instrumentExecutionResult receives is TypedGraphQLError{message='java.lang.IllegalStateException: Expected key 'myDemoKey' in received federated values map does not exist.', locations=[], path=[_entities], extensions={errorType=INTERNAL}}. The ErrorUtils.sanitizeErrorPaths() call then sets the type to INTERNAL.

hpuac avatar May 19 '22 14:05 hpuac

Thanks @hpuac, it should be consistent with BAD_REQUEST in both cases.

berngp avatar May 20 '22 00:05 berngp

Closing this issue since it should be addressed in the latest release. Please reopen, if issue exists.

srinivasankavitha avatar Jun 17 '22 20:06 srinivasankavitha

Hey @srinivasankavitha, sorry for the delay but I was now able to re-test it with DGS 5.0.5. The following errors are still not exposed to micrometer as expected:

  • Exposed as INTERNAL: {"message":"com.netflix.graphql.dgs.exceptions.MissingFederatedQueryArgument: The federated query is missing field(s) __typename","locations":[],"path":["_entities"],"extensions":{"errorType" :"INTERNAL"}}
  • Exposed as unknown: {"message":"Variable 'representations' has an invalid value: Variable 'representations' has coerced Null value for NonNull type '[_Any!]!'","locations":[{"line":1,"column":23}],"extensions":{ "classification":"ValidationError"}}
  • Exposed as unknown: {"message":"Variable 'input' has an invalid value: Variable 'input' has coerced Null value for NonNull type 'MyDemoInput!'","locations":[{"line":1,"column":36}],"extensions":{"c lassification":"ValidationError"}}
  • Exposed as unknown: {"message":"The variables input contains a field name 'myDemoName' that is not defined for input object type 'MyDemoInput' ","extensions":{"classification":"ValidationError"}}
  • Does not get exposed to micrometer as error at all: {"message":"The query is null or empty.","locations":[],"extensions":{"errorType":"BAD_REQUEST"}}

hpuac avatar Jul 05 '22 16:07 hpuac

Hey @berngp and @srinivasankavitha, should I create a new issue or will you reopen this one? 🙂

hpuac avatar Jul 07 '22 07:07 hpuac

Let's keep this one.

berngp avatar Jul 07 '22 16:07 berngp

@berngp do you have the rights to reopen it? I don't have any button for it.

hpuac avatar Jul 07 '22 19:07 hpuac