-
Notifications
You must be signed in to change notification settings - Fork 614
[CLEANUP][SONAR][LOW]: Deprecated datetime.utcnow() usage in main.py #2377
Copy link
Copy link
Labels
COULDP3: Nice-to-have features with minimal impact if left out; included if time permitsP3: Nice-to-have features with minimal impact if left out; included if time permitschoreLinting, formatting, dependency hygiene, or project maintenance choresLinting, formatting, dependency hygiene, or project maintenance choresgood first issueGood for newcomersGood for newcomerspythonPython / backend development (FastAPI)Python / backend development (FastAPI)sonarSonarQube code quality findingsSonarQube code quality findings
Milestone
Description
Severity: LOW
File: mcpgateway/main.py
Line: 5962
Rule: python:S6903
Description
The code uses datetime.utcnow() which is deprecated in Python 3.12. It creates a naive datetime without timezone info.
Code
# Line 5962
"timestamp": datetime.utcnow().isoformat(),Impact
datetime.utcnow()returns a naive datetime (no timezone info)- Deprecated in Python 3.12, will be removed in future versions
- Can cause timezone-related bugs when comparing with aware datetimes
Suggested Fix
Use timezone-aware datetime:
from datetime import datetime, timezone
"timestamp": datetime.now(timezone.utc).isoformat(),Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
COULDP3: Nice-to-have features with minimal impact if left out; included if time permitsP3: Nice-to-have features with minimal impact if left out; included if time permitschoreLinting, formatting, dependency hygiene, or project maintenance choresLinting, formatting, dependency hygiene, or project maintenance choresgood first issueGood for newcomersGood for newcomerspythonPython / backend development (FastAPI)Python / backend development (FastAPI)sonarSonarQube code quality findingsSonarQube code quality findings