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

Dev UI/Swagger: Support expansion of properties in path #46670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Sgitario
Copy link
Contributor

@Sgitario Sgitario commented Mar 7, 2025

When configuring the swagger UI path as:

quarkus.swagger-ui.path=/api/${quarkus.application.name}/internal/swagger-ui

Note that you can use any property other than quarkus.application.name.
This fails with:

2025-03-06 15:34:26,557 ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.devui.deployment.menu.EndpointsProcessor#createEndpointsPage threw an exception: java.lang.IllegalArgumentException: Specified path is an invalid URI. Path was /api/${quarkus.application.name}/internal/swagger-ui
        at io.quarkus.deployment.util.UriNormalizationUtil.toURI(UriNormalizationUtil.java:52)
        at io.quarkus.deployment.util.UriNormalizationUtil.normalizeWithBase(UriNormalizationUtil.java:107)
        at io.quarkus.vertx.http.deployment.NonApplicationRootPathBuildItem.resolvePath(NonApplicationRootPathBuildItem.java:165)
        at io.quarkus.devui.deployment.menu.EndpointsProcessor.createEndpointsPage(EndpointsProcessor.java:29)
        at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
        at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
        at io.quarkus.builder.BuildContext.run(BuildContext.java:255)
        at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
        at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
        at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
        at java.base/java.lang.Thread.run(Thread.java:840)
        at org.jboss.threads.JBossThread.run(JBossThread.java:499)
Caused by: java.net.URISyntaxException: Illegal character in path at index 6: /api/${quarkus.application.name}/internal/swagger-ui
        at java.base/java.net.URI$Parser.fail(URI.java:2976)

This issue was introduced as part of the changes in #43950.

One solution is to use the ConfigProvider API to resolve the property since this already expand all the properties. @radcortez can you confirm if this is ok?

Testing these changes, I can now see that the path is correct:

Screenshot From 2025-03-07 14-30-07

This is using a Quarkus example named "resteasy".

Fixes #46662

This comment has been minimized.

@radcortez
Copy link
Member

There is another similar piece here:

private static String getProperty(ConfigurationBuildItem configurationBuildItem,
String propertyKey) {
// strictly speaking we know 'quarkus.swagger-ui.path' is build time property
// and 'quarkus.smallrye-graphql.ui.root-path' is build time with runtime fixed,
// but I wanted to make this bit more robust till we have DEV UI tests
// that will fail when this get changed in the future, then we can optimize this
ConfigValue configValue = configurationBuildItem
.getReadResult()
.getAllBuildTimeValues()
.get(propertyKey);
if (configValue == null || configValue.getValue() == null) {
configValue = configurationBuildItem
.getReadResult()
.getBuildTimeRunTimeValues()
.get(propertyKey);
} else {
return configValue.getValue();
}
if (configValue == null || configValue.getValue() == null) {
configValue = configurationBuildItem
.getReadResult()
.getRunTimeDefaultValues()
.get(propertyKey);
}
return configValue != null ? configValue.getValue() : null;
}

Quite frankly, I have no idea why it was done that way, but I usually prefer to confirm if there is some particular use case that we are not covering with a simple query to the Config system?

//cc @phillip-kruger @michalvavrik

@Sgitario
Copy link
Contributor Author

There is another similar piece here:

private static String getProperty(ConfigurationBuildItem configurationBuildItem,
String propertyKey) {
// strictly speaking we know 'quarkus.swagger-ui.path' is build time property
// and 'quarkus.smallrye-graphql.ui.root-path' is build time with runtime fixed,
// but I wanted to make this bit more robust till we have DEV UI tests
// that will fail when this get changed in the future, then we can optimize this
ConfigValue configValue = configurationBuildItem
.getReadResult()
.getAllBuildTimeValues()
.get(propertyKey);
if (configValue == null || configValue.getValue() == null) {
configValue = configurationBuildItem
.getReadResult()
.getBuildTimeRunTimeValues()
.get(propertyKey);
} else {
return configValue.getValue();
}
if (configValue == null || configValue.getValue() == null) {
configValue = configurationBuildItem
.getReadResult()
.getRunTimeDefaultValues()
.get(propertyKey);
}
return configValue != null ? configValue.getValue() : null;
}

Thanks for spotting this!

Quite frankly, I have no idea why it was done that way, but I usually prefer to confirm if there is some particular use case that we are not covering with a simple query to the Config system?

//cc @phillip-kruger @michalvavrik

By Config system, do you mean using ConfigProvider.getConfig().getValue()?

Anyways, yeah, let's wait for more feedback.

@radcortez
Copy link
Member

By Config system, do you mean using ConfigProvider.getConfig().getValue()?

Yes, and I'm not sure why the current code is accessing the configuration as is. That suspicious comment requires further clarification.

@michalvavrik
Copy link
Member

Quite frankly, I have no idea why it was done that way, but I usually prefer to confirm if there is some particular use case that

we are not covering with a simple query to the Config system?

I always look what others do, it wasn't clear to me for a long time if ConfigProvider.getConfig() inside of a build step is alright. Maybe it was clear to @radcortez, but I looked for it and didn't find it :-). Anyway, this is DEV UI, so changing it is fine. I think I just made mistake, that's all.

@radcortez
Copy link
Member

I always look what others do, it wasn't clear to me for a long time if ConfigProvider.getConfig() inside of a build step is alright.

Yes, this is ok. We just need to be aware that the

@radcortez radcortez closed this Mar 10, 2025
@quarkus-bot quarkus-bot bot added triage/invalid This doesn't seem right and removed triage/backport labels Mar 10, 2025
@radcortez
Copy link
Member

I always look what others do, it wasn't clear to me for a long time if ConfigProvider.getConfig() inside of a build step is alright.

Yes, this is fine. Remeber that the Config instance only has access to build time configuration when in build steps.

Ideally, it should use io.quarkus.swaggerui.deployment.SwaggerUiConfig#path.

@Sgitario
Copy link
Contributor Author

@radcortez why did you close this pull request with invalid? I was understanding that my changes about using the ConfigProvider API was ok

@radcortez
Copy link
Member

Sorry, I've probably hit the wrong button.

@radcortez radcortez reopened this Mar 10, 2025
@quarkus-bot quarkus-bot bot removed the triage/invalid This doesn't seem right label Mar 10, 2025

This comment has been minimized.

@Sgitario
Copy link
Contributor Author

@radcortez I've just updated the pull request to also update this: #46670 (comment)

Copy link

quarkus-bot bot commented Mar 11, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit c11f15e.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
✔️ JVM Tests - JDK 17 Logs Raw logs 🔍
✔️ JVM Tests - JDK 21 Logs Raw logs 🔍
JVM Tests - JDK 17 Windows Build Failures Logs Raw logs 🔍

Full information is available in the Build summary check run.
You can consult the Develocity build scans.

Failures

⚙️ JVM Tests - JDK 17 Windows #

- Failing: extensions/websockets-next/deployment 

📦 extensions/websockets-next/deployment

io.quarkus.websockets.next.test.security.HttpUpgradePermitAllAnnotationTest. - History - More details - Source on GitHub

java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:305)
	at io.quarkus.test.QuarkusUnitTest.beforeAll(QuarkusUnitTest.java:697)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.OutOfMemoryError: Metaspace

Flaky tests - Develocity

⚙️ JVM Tests - JDK 17

📦 extensions/smallrye-reactive-messaging-kafka/deployment

io.quarkus.smallrye.reactivemessaging.kafka.deployment.testing.KafkaDevServicesContinuousTestingWorkingAppPropsTestCase.testContinuousTestingScenario3 - History

  • io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.apicurio.registry.devservice.DevServicesApicurioRegistryProcessor\#startApicurioRegistryDevService threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/apicurio/apicurio-registry-mem:2.4.2.Final at io.quarkus.apicurio.registry.devservice.DevServicesApicurioRegistryProcessor.startApicurioRegistryDevService(DevServicesApicurioRegistryProcessor.java:90) at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732) at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856) - java.lang.RuntimeException
java.lang.RuntimeException: 
io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.apicurio.registry.devservice.DevServicesApicurioRegistryProcessor#startApicurioRegistryDevService threw an exception: java.lang.RuntimeException: org.testcontainers.containers.ContainerLaunchException: Container startup failed for image quay.io/apicurio/apicurio-registry-mem:2.4.2.Final
	at io.quarkus.apicurio.registry.devservice.DevServicesApicurioRegistryProcessor.startApicurioRegistryDevService(DevServicesApicurioRegistryProcessor.java:90)
	at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:732)
	at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:856)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:255)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)

@Sgitario
Copy link
Contributor Author

Hey, @gsmet I've not contributed to Quarkus for a while and wanted to double check if it was ok to merge these changes even when the check "Quarkus CI / JVM Tests - JDK 17 Windows (pull_request)" is failing.
I would say this check is unrelated to these changes.

@michalvavrik
Copy link
Member

Hey, @gsmet I've not contributed to Quarkus for a while and wanted to double check if it was ok to merge these changes even when the check "Quarkus CI / JVM Tests - JDK 17 Windows (pull_request)" is failing. I would say this check is unrelated to these changes.

I think I added that test, it should be unrelated. I can't see in Develocity history for OOM happening and I presume OOM can happen to due to what happens before that test is executed, so I'll not debug it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quarkus fails to expand quarkus.application.name in DEV mode
5 participants