You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FOCA's MongoDB registration in foca/database/register_mongodb.py currently only supports individual environment variables (MONGO_HOST, MONGO_PORT, MONGO_USERNAME, MONGO_PASSWORD, MONGO_DBNAME) and constructs the MongoDB URI internally. This prevents users from providing complete MongoDB connection strings with advanced features like:
Pre-constructed URIs from external secret management
Requested Enhancement
Add support for a MONGO_URI environment variable that, when present, takes precedence over individual component variables while maintaining full backwards compatibility.
Hi! I’d be happy to work on this issue if it’s still available.
From reading the current MongoDB registration logic in foca/database/register_mongodb.py, FOCA currently constructs the MongoDB connection string internally using the following environment variables:
MONGO_HOST
MONGO_PORT
MONGO_USERNAME
MONGO_PASSWORD
MONGO_DBNAME
My proposed implementation approach is:
1. Add support for a MONGO_URI environment variable
If MONGO_URI is present, the MongoDB client will be initialized directly using this URI instead of constructing one from the individual variables.
2. Preserve full backward compatibility
The current configuration using the individual variables will remain unchanged and continue to work when MONGO_URI is not provided.
3. Define clear precedence rules
Configuration precedence will be:
MONGO_URI > individual Mongo variables
Meaning:
If MONGO_URI exists → use it directly
Otherwise → fall back to the current URI construction logic
4. Keep the change localized
I plan to implement the change directly in register_mongodb.py so that the rest of the database initialization logic remains unchanged.
5. Handle advanced Mongo connection scenarios
Using MONGO_URI will allow deployments to support features that are currently difficult or impossible with the existing configuration:
Activity
minhpham1810 commentedon Mar 16, 2026
Hi! I’d be happy to work on this issue if it’s still available.
From reading the current MongoDB registration logic in
foca/database/register_mongodb.py, FOCA currently constructs the MongoDB connection string internally using the following environment variables:MONGO_HOSTMONGO_PORTMONGO_USERNAMEMONGO_PASSWORDMONGO_DBNAMEMy proposed implementation approach is:
1. Add support for a
MONGO_URIenvironment variableIf
MONGO_URIis present, the MongoDB client will be initialized directly using this URI instead of constructing one from the individual variables.2. Preserve full backward compatibility
The current configuration using the individual variables will remain unchanged and continue to work when
MONGO_URIis not provided.3. Define clear precedence rules
Configuration precedence will be:
Meaning:
MONGO_URIexists → use it directly4. Keep the change localized
I plan to implement the change directly in
register_mongodb.pyso that the rest of the database initialization logic remains unchanged.5. Handle advanced Mongo connection scenarios
Using
MONGO_URIwill allow deployments to support features that are currently difficult or impossible with the existing configuration:mongodb+srv)6. Add/update tests and documentation
I will add tests (or update existing ones if applicable) to verify:
MONGO_URIonly configurationI will also update relevant documentation/examples to mention the new configuration option.
Please let me know if this approach aligns with the intended behavior before I start implementing.
feat: add MONGO_URI environment variable support (elixir-cloud-aai#253)
Revert "feat: add MONGO_URI environment variable support (elixir-clou…