Replies: 3 comments 2 replies
|
This looks like a bug. When The relevant code path is in Workaround 1: Use a valid placeholder connection string that passes URL parsing: quarkus.mongodb.connection-string=mongodb://placeholder:placeholder@x.y.z.w:27017/db
quarkus.mongodb.active=falseThen replace it at runtime when constructing your manual client. Workaround 2: Use an environment variable with a valid default: quarkus.mongodb.connection-string=${MONGODB_URI:mongodb://localhost:27017}
quarkus.mongodb.active=falseThe default value passes parsing, and your application code uses the real templated URI when building the manual Workaround 3: Use a profile-based config to avoid the property entirely in dev/test: # application.properties
%prod.quarkus.mongodb.connection-string=${MONGODB_URI}
%prod.quarkus.mongodb.active=false
# In dev/test, don't set the property at allThis is likely worth filing as a bug — the expectation from the docs is that |
|
This is indeed a bug — the connection string is parsed before the Option 1: Provide a syntactically valid placeholder quarkus.mongodb.active=false
quarkus.mongodb.connection-string=mongodb://localhost:27017Even if the server does not exist, the string parses correctly and no connection pool is initialized when Option 2: Use profiles to exclude the config entirely # Only define the URI in profiles where MongoDB is actually used
%prod.quarkus.mongodb.connection-string=${MONGO_URI}
%dev.quarkus.mongodb.connection-string=mongodb://localhost:27017When the profile does not define the property, it will not be parsed at all. Worth opening an issue if one does not exist yet — the expected behavior when |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
Quarkus 3.32 (#51013) introduced capability to disable default MongoDB client: https://quarkus.io/guides/mongodb#activate-or-deactivate-mongo-clients.
This allows you to disable client in case you will create it dynamically "by hand". The problem is that even if I set
active: false, it still tries to encode/parse connection string and throws an error in case connection string is not valid:In our case we pass connection string such as:
mongodb://%s:%s@x.y.z.w....as we use that as template to replace it with username & password to get the final connection string that is then passed to the manually constructed client (MongoClientSettings settings = MongoClientSettings.builder().applyConnectionString()...).Is this expected behavior? We can do a workaround, but from the documentation I thought that feature would enable us to use the
connection-stringproperty.All reactions