Skip to content
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

Autogenerated application with oidc-db-token-state-manager fails to be built #39408

Closed
fedinskiy opened this issue Mar 13, 2024 · 8 comments · Fixed by #39432
Closed

Autogenerated application with oidc-db-token-state-manager fails to be built #39408

fedinskiy opened this issue Mar 13, 2024 · 8 comments · Fixed by #39432
Labels
area/oidc kind/bug Something isn't working
Milestone

Comments

@fedinskiy
Copy link
Contributor

fedinskiy commented Mar 13, 2024

Describe the bug

I use create option of quarkus-maven-plugin to generate an app with oidc-db-token-state-manager extension. When I try to build the app (without any changes) it fails.

Expected behavior

The app is built

Actual behavior

[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:3.8.1:build (default) on project reproducer-oidc: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR] 	[error]: Build step io.quarkus.oidc.db.token.state.manager.OidcDbTokenStateManagerProcessor#produceDbTokenStateManagerBean threw an exception: java.lang.NullPointerException: Cannot read field "reactiveClient" because "sqlClientBuildItem" is null
[ERROR] 	at io.quarkus.oidc.db.token.state.manager.OidcDbTokenStateManagerProcessor.produceDbTokenStateManagerBean(OidcDbTokenStateManagerProcessor.java:47)
[ERROR] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[ERROR] 	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
[ERROR] 	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
[ERROR] 	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
[ERROR] 	at java.base/java.lang.Thread.run(Thread.java:1583)
[ERROR] 	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] 
[ERROR] 	[error]: Build step io.quarkus.oidc.db.token.state.manager.OidcDbTokenStateManagerProcessor#createDbTokenStateInitializerProps threw an exception: java.lang.NullPointerException: Cannot read field "reactiveClient" because "sqlClientBuildItem" is null
[ERROR] 	at io.quarkus.oidc.db.token.state.manager.OidcDbTokenStateManagerProcessor.createDbTokenStateInitializerProps(OidcDbTokenStateManagerProcessor.java:115)
[ERROR] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[ERROR] 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[ERROR] 	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:849)
[ERROR] 	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
[ERROR] 	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
[ERROR] 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
[ERROR] 	at java.base/java.lang.Thread.run(Thread.java:1583)
[ERROR] 	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] -> [Help 1]

How to Reproduce?

  1. Generate the app: mvn -Dquarkus-plugin.version=3.8.1 -DquarkusRegistryClient=false io.quarkus:quarkus-maven-plugin:3.8.1:create -DprojectGroupId=io.quarkus.qe -DprojectVersion=1.0.0-SNAPSHOT -Dextensions=oidc-db-token-state-manager -DprojectArtifactId=reproducer
  2. cd reproducer
  3. Build the app: mvn clean package -DskipTests

Output of uname -a or ver

6.7.3-200.fc39.x86_64

Output of java -version

Java version: 21.0.1, vendor: Eclipse Adoptium

Quarkus version or git rev

3.8.1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)

Additional information

Same error for 3.8.2

@fedinskiy fedinskiy added the kind/bug Something isn't working label Mar 13, 2024
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 13, 2024

/cc @pedroigor (oidc), @sberyozkin (oidc)

@sberyozkin
Copy link
Member

This is expected, see https://github.com/quarkusio/quarkus/blob/main/extensions/oidc-db-token-state-manager/deployment/src/main/java/io/quarkus/oidc/db/token/state/manager/OidcDbTokenStateManagerProcessor.java#L96, you don't add any reactive client extensions, but it should've failed at that stage where it is checked for null.

The docs for the ValidationPhaseBuildItem suggest it is handled correctly.
@mkouba Can you please comment ?

@michalvavrik
Copy link
Member

michalvavrik commented Mar 13, 2024

Expected behavior The app is built is wrong expectation, but truth is that we should probably just fire config exception straight away because synthetic bean build item is produced for phrase 3 and and validation errors are only produced in phase 5, so the NPE will always win. Didn't know about that.

@mkouba
Copy link
Contributor

mkouba commented Mar 14, 2024

Hm, I would expect the build to fail as the ReactiveSqlClientBuildItem is a SimpleBuildItem and thus if no such build item is produced then a dependency is not satisfied (you would need to consume Optional<ReactiveSqlClientBuildItem> instead). But it seems that we only fail with ChainBuildException if there's no producer for the given build item, i.e. we don't check the actual runtime value of the producer (the return value of a build step) and simply pass null to the build step argument which isn't ideal I think?

CC @dmlloyd

@dmlloyd
Copy link
Member

dmlloyd commented Mar 14, 2024

Right, I agree that we should not allow null to be produced.

@gsmet gsmet modified the milestones: 3.10 - main, 3.9.0.CR2 Mar 14, 2024
@mkouba
Copy link
Contributor

mkouba commented Mar 14, 2024

Right, I agree that we should not allow null to be produced.

I can try to send a PR with a fix but I'm afraid that it will break a lot of things :-(

@dmlloyd
Copy link
Member

dmlloyd commented Mar 14, 2024

I think it's probably OK to break things on a fix like this. But if you'd prefer not to do it, I totally understand. I can add it to my list.

@mkouba
Copy link
Contributor

mkouba commented Mar 14, 2024

Let's see how many things will break first...

mkouba added a commit to mkouba/quarkus that referenced this issue Mar 14, 2024
- to avoid unexpected NullPointerException
- build steps should consume java.util.Optional instead
- follow-up to quarkusio#39408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/oidc kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants