-
-
Notifications
You must be signed in to change notification settings - Fork 523
IllegalStateException: Duplicate key
when two endpoints at the same URL with same header exist
#1985
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
Comments
Thank you for your analysis. |
I may be able to try soon-ish, but I am not sure how to best fix the problem, since I don't understand the bigger picture. Do you think it would be enough to simply skip duplicate headers? That would be easy enough I suppose |
This is a good start! |
Without any response. i have added a workaround. |
…RL with same header exist. Fixes #1985.
looks good, thanks! |
…RL with same header exist. Fixes #1985.
I am using springdoc-openapi-ui 1.6.13 in conjunction with graphql-spqr 0.12.0 and its accompanying graphql-spqr-spring-boot-starter 0.0.6 in a spring-boot application 2.7.6.
When trying to access
http://localhost:8080/v3/api-docs
to see the generated OpenAPI, I get an error:I used this test, but just launching the application and hitting
http://localhost:8080/v3/api-docs
should be equivalent:I was able to narrow the problem down a bit:
graphql-spqr-spring-boot-starter
provides a rest controller for a/graphql
endpoint, which includes the headersheaders = { "Connection!=Upgrade", "Connection!=keep-alive, Upgrade" }
for two endpoints as seen here:Springdoc later parses this information using this code:
which results in the headers
["Connection!=Upgrade", "Connection!=keep-alive, Upgrade"]
.MethodAttributes#setHeaders
later interprets those header expressions as plain header, splitting at=
and adding a header calledConnection!
to the headers map.This in and of itself already looks like a bug, but at this point it's just a precondition for the following:
Because
graphql-spqr-spring-boot-starter
's rest controller contains two GET endpoints that only differ in theirproduces
mime type,OpenApiResource
'scalculatePath
method is run for both. It constructs a newOperation
object the first time but reuses the already defined operation, as seen in AbstractOpenApiResource#calculatePath:A bit further down
fillParametersList
is called, which derivesParameter
s from http headers. Here, a second duplicateclass Parameter { name: Connection!, ... }
gets added usingparametersList.addAll(headersMap)
.This later on causes a
IllegalStateException
in AbstractRequestService#getParameterLinkedHashMap:It would be nice if springdoc could process the graphql endpoint in some meaningful way without crashing.
The easy workaround right now is to exclude the graphql endpoint from springdoc in the
application.properties
:The text was updated successfully, but these errors were encountered: