Skip to content

Conversation

@nmveeresh
Copy link
Collaborator

Closes: #1415

Fix observability_exclude_paths Env Parsing Issue

Summary:
This PR addresses the SettingsError encountered when loading the OBSERVABILITY_EXCLUDE_PATHS environment variable in mcpgateway. The error occurred because the environment variable was previously provided as a comma-separated string, which pydantic-settings could not parse into a List[str].

Changes:

  • Updated config.py to ensure observability_exclude_paths is correctly parsed from environment variables as a JSON array.

  • Modified .env example and documentation to use JSON array format:

    OBSERVABILITY_EXCLUDE_PATHS='["/health", "/healthz", "/ready", "/metrics", "/static/.*"]'
    

Impact:

  • Prevents runtime errors on application startup due to settings parsing issues.
  • Compatible with .env files, shell exports, and Helm/Kubernetes environment variables.
  • Ensures observability paths are correctly loaded and applied for tracing exclusion.

Testing:

  • Verified settings.observability_exclude_paths loads correctly from all sources.
  • Confirmed that default values are applied when the env variable is unset.
  • Local and containerized setups tested to ensure no regressions.
    python -c "from mcpgateway.config import settings; print(settings.observability_exclude_paths)"

Output:

['/health', '/healthz', '/ready', '/metrics', '/static/.*']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SettingsError raised when parsing environment variable observability_exclude_paths in Pydantic settings

2 participants