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

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

Closed
SvenWoltmann opened this issue Nov 10, 2021 · 3 comments · Fixed by #21530
Labels
area/rest-client kind/bug Something isn't working
Milestone

Comments

@SvenWoltmann
Copy link

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

@SvenWoltmann SvenWoltmann added the kind/bug Something isn't working label Nov 10, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Nov 10, 2021

/cc @michalszynkiewicz

@SvenWoltmann
Copy link
Author

I could finally get this running with the help of this comment: #12968 (comment)

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
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest-client kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants