Skip to content

Commit 88979ad

Browse files
fix(config): corregge validator Pydantic v2 per leggere QDRANT_API_KEY e QDRANT_URL da environment
1 parent 6242e99 commit 88979ad

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/config.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,19 @@ class QdrantConfig(BaseModel):
6666
url: Optional[str] = Field(default=None, description="Qdrant URL")
6767
api_key: Optional[str] = Field(default=None, description="API key if required")
6868

69-
@field_validator('url')
69+
@field_validator('url', mode='before')
70+
@classmethod
7071
def set_url_from_env(cls, v):
7172
"""Set URL from environment if not provided."""
72-
if v is None:
73+
if v is None or v == '':
7374
return os.getenv('QDRANT_URL', 'http://localhost:6333')
7475
return v
7576

76-
@field_validator('api_key')
77+
@field_validator('api_key', mode='before')
78+
@classmethod
7779
def set_api_key_from_env(cls, v):
7880
"""Set API key from environment if not provided."""
79-
if v is None:
81+
if v is None or v == '':
8082
return os.getenv('QDRANT_API_KEY')
8183
return v
8284

0 commit comments

Comments
 (0)