Skip to content

Fix COREMS_DATABASE_URL env var not overriding hardcoded default#30

Open
robertyoung3 wants to merge 1 commit intoEMSL-Computing:masterfrom
robertyoung3:fix/database-url-env-override
Open

Fix COREMS_DATABASE_URL env var not overriding hardcoded default#30
robertyoung3 wants to merge 1 commit intoEMSL-Computing:masterfrom
robertyoung3:fix/database-url-env-override

Conversation

@robertyoung3
Copy link

Summary

  • The MolecularFormulaSearchSettings.url_database field has a hardcoded default pointing to localhost:5432
  • The __post_init__ method checks COREMS_DATABASE_URL only when url_database is empty, but the hardcoded default means it's never empty — so the env var from .env (which points to the molformdb compose service) is silently ignored
  • Moves the os.getenv("COREMS_DATABASE_URL", ...) call to the field default so it's respected at initialization time, while preserving the localhost fallback for non-compose setups

Test plan

  • Verify SearchMolecularFormulas connects to the molformdb service when using docker-compose.yml with the provided .env
  • Verify localhost fallback still works when COREMS_DATABASE_URL is not set

🤖 Generated with Claude Code

The MolecularFormulaSearchSettings dataclass has a hardcoded
url_database default pointing to localhost:5432. The __post_init__
method checks COREMS_DATABASE_URL only when url_database is empty,
but the hardcoded default means it's never empty — so the env var
from .env (which points to the 'molformdb' compose service) is
silently ignored.

Move the os.getenv() call to the field default so COREMS_DATABASE_URL
is respected at initialization time. The localhost fallback is
preserved for non-compose setups.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant