quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.63k stars 2.64k forks source link

REST Client Configuration via Uppercase/Underscore Environment Variables Stopped Working in 2.4.0 #21345

Closed SvenWoltmann closed 2 years ago

SvenWoltmann commented 2 years ago

Describe the bug

I have the following REST client:

package com.ionos.cloud.auth.user;
...
@RegisterRestClient(configKey = "user-api-rest-client")
public interface UserApiRestClient { ... }

I used to configure it via the following environment variable (as we can only use uppercase characters and underscores in our environment):

USER_API_REST_CLIENT_MP_REST_URL

This worked perfectly fine up to Quarkus 2.3.1.

In Quarkus 2.4.0 + 2.4.1, I get the following error message (I've added line breaks for better readability):

Caused by: java.lang.IllegalArgumentException: Unable to determine the proper baseUrl/baseUri.

Consider registering using @RegisterRestClient(baseUri="someuri"), 
                           @RegisterRestClient(configKey="orkey"), 
or by adding 'quarkus.rest-config."user-api-rest-client".url' 
          or 'quarkus.rest-config."user-api-rest-client".uri' 
to your Quarkus configuration

First of all, there's an error in that message, it should be "quarkus.rest-client", not "quarkus.rest-config" (see https://quarkus.io/guides/rest-client#create-the-configuration).

But that's not the issue here.

As per the documentation, all these configuration keys work fine (in a test environment):

user-api-rest-client/mp-rest/url
quarkus.rest-client.user-api-rest-client.url
quarkus.rest-client.user-api-rest-client.uri
quarkus.rest-client."user-api-rest-client".url
quarkus.rest-client."user-api-rest-client".uri
quarkus.rest-client."com.ionos.cloud.auth.user.UserApiRestClient".url
quarkus.rest-client."com.ionos.cloud.auth.user.UserApiRestClient".uri

However, as I said before, in our production environment, I can use only uppercase and underscore.

But all these keys do not work:

USER_API_REST_CLIENT_MP_REST_URL
QUARKUS_REST_CLIENT_USER_API_REST_CLIENT_URL
QUARKUS_REST_CLIENT_USER_API_REST_CLIENT_URI
QUARKUS_REST_CLIENT__USER_API_REST_CLIENT__URL
QUARKUS_REST_CLIENT__USER_API_REST_CLIENT__URI
QUARKUS_REST_CLIENT__COM_IONOS_CLOUD_AUTH_USER_USERAPIRESTCLIENT__URL
QUARKUS_REST_CLIENT__COM_IONOS_CLOUD_AUTH_USER_USERAPIRESTCLIENT__URI

Expected behavior

Uppercase/underscore environment variables - such as the following ones - should be usable for REST client configuration:

<CONFIG_KEY>_MP_REST_URL
QUARKUS_REST_CLIENT_<CONFIG_KEY>_URL
QUARKUS_REST_CLIENT_<CONFIG_KEY>_URI
QUARKUS_REST_CLIENT__<CONFIG_KEY>__URL
QUARKUS_REST_CLIENT__<CONFIG_KEY>__URI
QUARKUS_REST_CLIENT__<FULLY_QUALIFIED_CLASS_NAME>__URL
QUARKUS_REST_CLIENT__<FULLY_QUALIFIED_CLASS_NAME>__URI

Actual behavior

None of the following uppercase/underscore environment variables are usable for REST client configuration:

<CONFIG_KEY>_MP_REST_URL
QUARKUS_REST_CLIENT_<CONFIG_KEY>_URL
QUARKUS_REST_CLIENT_<CONFIG_KEY>_URI
QUARKUS_REST_CLIENT__<CONFIG_KEY>__URL
QUARKUS_REST_CLIENT__<CONFIG_KEY>__URI
QUARKUS_REST_CLIENT__<FULLY_QUALIFIED_CLASS_NAME>__URL
QUARKUS_REST_CLIENT__<FULLY_QUALIFIED_CLASS_NAME>__URI

How to Reproduce?

  1. Create a REST client with a config key.
  2. Try to configure it via environment variables with only uppercase characters and underscores.

Output of uname -a or ver

Linux debian 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux

Output of java -version

openjdk version "16.0.1" 2021-04-20

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.4.0, 2.4.1

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

Apache Maven 3.6.3

Additional information

No response

quarkus-bot[bot] commented 2 years ago

/cc @michalszynkiewicz

SvenWoltmann commented 2 years ago

I could finally get this running with the help of this comment: https://github.com/quarkusio/quarkus/issues/12968#issuecomment-950851206

If I add this to my application properties:

quarkus.rest-client."user-api-rest-client".url=http://overwrite-me

Then I can overwrite the setting with this environment variable:

QUARKUS_REST_CLIENT__USER_API_REST_CLIENT__URL

Is it intended to be like this?

radcortez commented 2 years ago

Is it intended to be like this?

No. Unfortunately, one big change we did on the REST Client config broke a few things. I'm sorry for the inconvenience. We will have a look.