fix: reject an unrecognized DB_ENGINE instead of using SQLite (#8605)

This commit is contained in:
yi111 authored and GitHub committed 2026-10-21 18:28:49 +00:00
1 parent 2c46e40d33
commit 4a8e710f8f
2 files changed
+12 -1

No files matched your search

+5 -1
View File
@@ -81,7 +81,11 @@ class PostgresProvider(AbstractDBProvider, BaseSettings):
def db_provider_factory(provider_name: str, data_dir: Path, env_file: Path, env_encoding="utf-8") -> AbstractDBProvider:
# Documented engines are only sqlite and postgres. Anything else used to
# fall through to SQLite, so a typo such as "postgress" started a Postgres
# deployment on a local file and reported success.
if provider_name == "postgres":
return PostgresProvider(_env_file=env_file, _env_file_encoding=env_encoding)
else:
if provider_name == "sqlite":
return SQLiteProvider(data_dir=data_dir)
raise ValueError(f"DB_ENGINE must be 'sqlite' or 'postgres', got {provider_name!r}")
+7
View File
@@ -69,6 +69,13 @@ def test_pg_connection_args(monkeypatch):
assert app_settings.DB_URL == "postgresql+psycopg2://mealie:mealie@postgres:5432/mealie"
def test_unknown_db_engine_is_rejected(monkeypatch):
monkeypatch.setenv("DB_ENGINE", "postgress")
get_app_settings.cache_clear()
with pytest.raises(ValueError, match="DB_ENGINE"):
get_app_settings()
psql_validation_cases = [
(
"unencoded_to_encoded_password",