bug: Some invalid queries get exposed as "unknown" or "Intenal" instead of "ValidationError" or "BadRequest" in micrometer
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
unknownin micrometer. - When modifying a federated GraphQL request and sending a variable that is not in the query, it gets exposed as errorTyoe
INTERNALin 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->instrumentExecutionResultreceives isgraphql.execution.InputMapDefinesTooManyFieldsException: The variables input contains a field name 'myDemoKey' that is not defined for input object type 'MyDemoInput'. TheErrorUtils.sanitizeErrorPaths()call then sets the type tounknown. - When the error type
INTERNALis exposed, the exception thatDgsGraphQLMetricsInstrumentation->instrumentExecutionResultreceives isTypedGraphQLError{message='java.lang.IllegalStateException: Expected key 'myDemoKey' in received federated values map does not exist.', locations=[], path=[_entities], extensions={errorType=INTERNAL}}. TheErrorUtils.sanitizeErrorPaths()call then sets the type toINTERNAL.
Thanks @hpuac, it should be consistent with BAD_REQUEST in both cases.
Closing this issue since it should be addressed in the latest release. Please reopen, if issue exists.
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"}}
Hey @berngp and @srinivasankavitha, should I create a new issue or will you reopen this one? 🙂
Let's keep this one.
@berngp do you have the rights to reopen it? I don't have any button for it.