-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
The SDK cannot be imported in applications that have other environment variables defined in their .env file. This prevents the SDK from being used in multi-service applications.
Root Cause
The MarketDataSettings class in settings.py uses pydantic-settings which defaults to extra='forbid' when parsing .env files. This causes a ValidationError when ANY environment variable exists in .env that isn't explicitly defined in the model.
Reproduction
-
Create a
.envfile with any variable not defined by MarketData:MY_APP_KEY=123 REDIS_HOST=localhost -
Try to import the SDK:
from marketdata.client import Client
-
Import fails immediately:
pydantic_core._pydantic_core.ValidationError: 2 validation errors for MarketDataSettings my_app_key Extra inputs are not permitted [type=extra_forbidden, input_value='123', input_type=str] redis_host Extra inputs are not permitted [type=extra_forbidden, input_value='localhost', input_type=str]
Impact
- SDK is unusable in any application with other environment variables in
.env - Prevents integration with frameworks like Django, Flask, FastAPI that use their own env vars
- Breaks in containerized environments where multiple services share
.envfiles - Error occurs at module load time, before any client code can run
Suggested Fix
Add extra='ignore' to the model configuration in settings.py:
model_config = ConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra='ignore' # Allow other env vars to exist
)Environment
- SDK version: v1.1.0
- Python: 3.13
- pydantic-settings: 2.x
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working