Skip to content

[BUG][TESTING]: Pytest warnings from outdated Pydantic patterns #197

@crivetimihai

Description

@crivetimihai

🐞 Bug Summary

Pytest run exposes warnings from outdated Pydantic patterns, deprecated stdlib functions, and third-party API changes.


🧩 Affected Component

Select the area of the project impacted:

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports

🔁 Steps to Reproduce

  1. Run pytest
  2. Review warnings summary
  3. Observe multiple deprecation notices from Pydantic, Python stdlib, and third-party libraries

🤔 Expected Behavior

No warnings should appear in test output under supported versions of dependencies.


📓 Logs / Error Output

📦 Field(..., env=...) is deprecated

Use json_schema_extra={"env": "FOO"} or use BaseSettings with model_config.

  • Replace Field(..., env=...) usages
    File: mcpgateway/config.py

📦 class Config is deprecated

Use model_config = ConfigDict(...) instead.

  • Replace all class Config: declarations
    Files: mcpgateway/schemas.py, mcpgateway/types.py

📦 Deprecated config keys
  • Rename allow_population_by_field_namevalidate_by_name
  • Rename schema_extrajson_schema_extra
    Files: mcpgateway/types.py, mcpgateway/schemas.py

📦 Legacy @validator and @root_validator
  • Replace @validator(...) with @field_validator(...)
  • Replace @root_validator(pre=True) with @model_validator(pre=True)
    File: mcpgateway/schemas.py
    Lines: 300, 359, 670, 686, 782, 797, 1051, 1136, 1165, 1204

📦 json_encoders is deprecated

Use @model_serializer and @field_serializer instead.

  • Remove json_encoders from model config
    File: mcpgateway/schemas.py

📦 .dict() and .parse_obj() deprecated
  • Replace .dict() with .model_dump()
    Files: admin.py, main.py, manager.py

  • Replace .parse_obj() with .model_validate()
    File: manager.py


🕒 datetime.utcnow() is deprecated

Use datetime.now(datetime.UTC) instead.

  • Replace all datetime.utcnow()
    Files:

    • tool_service.py
    • server_service.py
    • prompt_service.py
    • logging_service.py
    • manager.py
    • discovery.py
    • forward.py
    • version.py
    • create_jwt_token.py
    • Tests: test_manager.py, test_discovery.py, test_schemas.py, test_forward.py

⚠️ Missing await on coroutine
  • Add missing await response.raise_for_status()
    File: mcpgateway/services/tool_service.py:437

⚠️ HTTPX content warning
  • Replace data=... with content=... when uploading raw bytes
    File affected indirectly: httpx/_models.py:408

⚠️ Starlette TemplateResponse signature changed
  • Fix parameter order:
    From: TemplateResponse(name, {"request": request})
    To: TemplateResponse(request, name, {...})
    File: test_ui_version.py

🧠 Environment Info

Key Value
Version or commit main@latest
Container venv / local

🧩 Additional Context

See Pydantic v2 migration guide
Goal: silence all warnings to ensure forward compatibility and clean CI/CD runs.


Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions