python
config_error
ai_generated
true
pydantic_settings.exceptions.SettingsError: error parsing value for field "DATABASE_URL" from source "EnvSettingsSource"
ID: python/starlette-uvicorn-invalid-env
80%Fix Rate
83%Confidence
0Evidence
2024-09-04First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
A Pydantic BaseSettings field expects a URL/int/bool but the environment variable is malformed or empty.
generic中文
Pydantic BaseSettings 字段期望 URL/int/bool,但环境变量格式错误或为空。
Workarounds
-
92% success
from pydantic import PostgresDsn class Settings(BaseSettings): database_url: PostgresDsn -
95% success
export DATABASE_URL='postgresql://user:pass@localhost:5432/db'
Dead Ends
Common approaches that don't work:
-
80% fail
Downstream code receives None and fails at connect time.
-
85% fail
Silently connects to the wrong database.