Fix Pydantic Settings validation error for extra environment variables

- Added CONTENT field to Settings model with Optional type
- Set extra='ignore' in Config to allow extra environment variables
- Added the same config to custom BaseSettings implementation for consistency
- Added missing import for Optional type
This commit is contained in:
Automated Action 2025-06-02 09:21:34 +00:00
parent 6a19bf4aa7
commit ccf2bb983b

View File

@ -1,5 +1,6 @@
import os
from pathlib import Path
from typing import Optional
from pydantic import BaseModel
@ -16,6 +17,7 @@ except ImportError:
class Config:
env_file = ".env"
case_sensitive = True
extra = "ignore" # Allow extra fields from environment variables
def __init__(self, **kwargs):
# Load environment variables
@ -38,9 +40,13 @@ class Settings(BaseSettings):
DB_DIR: Path = Path("/app") / "storage" / "db"
DB_NAME: str = "db.sqlite"
# Environment variables that can be accessed via API
CONTENT: Optional[str] = None
class Config:
env_file = ".env"
case_sensitive = True
extra = "ignore" # Allow extra fields from environment variables
settings = Settings()