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 .env file 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
.env files
- 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
Description
The SDK cannot be imported in applications that have other environment variables defined in their
.envfile. This prevents the SDK from being used in multi-service applications.Root Cause
The
MarketDataSettingsclass insettings.pyusespydantic-settingswhich defaults toextra='forbid'when parsing.envfiles. This causes aValidationErrorwhen ANY environment variable exists in.envthat isn't explicitly defined in the model.Reproduction
Create a
.envfile with any variable not defined by MarketData:Try to import the SDK:
Import fails immediately:
Impact
.env.envfilesSuggested Fix
Add
extra='ignore'to the model configuration insettings.py:Environment