Open Sam-Kruglov opened 4 days ago
Thanks for the analysis but you are one step ahead of us. Can you show a minimal error handler code snippet that would trigger this so we can have a look?
Just throw any error. I believe it doesn't matter how you get to the exception handler, only matters that the handler itself throws an error.
@GraphQlExceptionHandler
fun handle(ex: ConstraintViolationException, env: DataFetchingEnvironment): List<GraphQLError> {
throw IllegalStateException("oops")
}
If my handler throws an error, then
DataFetcherHandlerMethod
(line 239) returnsMono.error(..)
, and thenAnnotatedControllerExceptionResolver
(line 241) tries to convert it toMono
again, which givesClassCastException
https://github.com/spring-projects/spring-graphql/blob/381c9f3cc06ed2c0dfd102d647b0d2feb2a4bd06/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerExceptionResolver.java#L239-L241
Specifically, in my case I see I threw an error from my handler
@GraphQlExceptionHandler fun handle(...): List<GraphQLError> {...}
that ended up here:After that, the
Mono.error
with my exception is attempted to be cast to the return type of my handler here: https://github.com/spring-projects/spring-graphql/blob/381c9f3cc06ed2c0dfd102d647b0d2feb2a4bd06/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/support/AnnotatedControllerExceptionResolver.java#L444-L449Line 446 evaluates to
false
because it is instance ofMono
and it tried to cast it toCollection<GraphQLError>
and then fails.And finally, I don't even get to see my actual error that got thrown in my exception handler in the logs, all I can see are these: