-
Notifications
You must be signed in to change notification settings - Fork 614
[BUG][TESTING]: Pytest warnings from outdated Pydantic patterns #197
Copy link
Copy link
Description
🐞 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
- Run
pytest - Review warnings summary
- 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_name→validate_by_name - Rename
schema_extra→json_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_encodersfrom 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.pyserver_service.pyprompt_service.pylogging_service.pymanager.pydiscovery.pyforward.pyversion.pycreate_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=...withcontent=...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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working