-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
ContextNotActiveException Issue in ResteasyReactiveClientResponseFilter when using @ActivateRequestContext and OidcClientRequestReactiveFilter #29960
Comments
/cc @pedroigor(oidc), @sberyozkin(oidc) |
I am not really sure how this could happen, so I would like to hear from @mkouba |
I think that we'll need someone with Reactive Messaging experience. In this particular case, a reactive client (implemented by Also #21367 (comment) and #27802 might be related. FTR I've tried to disable SmallRye Context Propagation for CDI contexts completely via |
I see that the request context is suspended during token retrieval in https://github.com/quarkusio/quarkus/blob/main/extensions/oidc-client-reactive-filter/runtime/src/main/java/io/quarkus/oidc/client/reactive/filter/runtime/AbstractOidcClientRequestReactiveFilter.java#L30 |
Indeed, it is a typical idea AFAIK in RestEasy reactive filters as otherwise it would have to block until the token is retrieved |
Yes, but that's not the CDI request context but resteasy-reactive request context. @geoand Could it be related? |
Likely, but I don't really know where to look |
I don't think the rest client supports propagating the CDI request scope: Line 535 in 3534e9d
It is debatable but I think it makes sense. The request scope is for incoming server requests, an outgoing REST client request doesn't require the CDI Request scope. |
FYI, OIDC token propagation reactive client filter (though it is not used in this reproducer) has a current request token injected |
I see that now, |
Ideally we would have the rest client keep the request scope when it's executed as part of an active request, but I am not sure how possible that will be... |
Describe the bug
Hi,
This one is weird and I gave up trying to find the root cause.
I made a small project that reproduces the issue here : https://github.com/npoirey/quarkus-repro-oidc-requestcontextnotactive
Basically, I have the following :
RequestScoped
bean (RequestContextBean
), that I use to propagate some context for logging purpose mainlyTotoConsumer
in the repo) annotated with@Blocking
, and@ActivateRequestContext
in order to use myRequestScopedBean
ClientLoggingFilter
), but one of them also has the providerOidcClientRequestReactiveFilter
the idea is
If I use the HTTP client WITHOUT OIDC, everything works fine.

You can see it by running the test
RequestContextBeanPropagationTest.testConsumesWithoutOidc()
:(don't pay attention to the 404, I didn't bother mocking the server)
In this test, I get traces from my filter
However, it doesnt work when using OIDC

You can see it by running the test
RequestContextBeanPropagationTest.testConsumesWithOidc()
:in this test, I dont get the logs from my filter. Instead it throws a
javax.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=org.acme.security.openid.connect.client.RequestContextBean, id=e4da94214e7ddc6f068456b5228496f1268add1a]
As a workaround, I added
@ActivateRequestContext
annotation on the filter itself, but obviously this only solves the exception - I still don't have the correct bean/context so my log is incompleteAs I had trouble understanding where the issue comes from, please let me know if I should create this issue on another project.
Thank you
Expected behavior
The requestContext should be active in ResteasyReactiveClientResponseFilter, even if it was activated manually beforehand via @ActivateRequestContext and the client is using OIDC.
In my example, RequestContextBeanPropagationTest.testConsumesWithOidc() should have the same output than RequestContextBeanPropagationTest.testConsumesWithoutOidc()
Actual behavior
throws a
javax.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=org.acme.security.openid.connect.client.RequestContextBean, id=e4da94214e7ddc6f068456b5228496f1268add1a]
How to Reproduce?
pull this repo
run
RequestContextBeanPropagationTest.testConsumesWithOidc()
Output of
uname -a
orver
No response
Output of
java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: