fix: convert datetime to ISO string for PostgreSQL timestamp compatibility - #23586
fix: convert datetime to ISO string for PostgreSQL timestamp compatibility#23586Jah-yee wants to merge 1 commit into
Conversation
…ompatibility Fixes timestamp type mismatch error in tool_registry_writer.py when inserting into LiteLLM_ToolTable. PostgreSQL expects timestamp format not timezone-aware datetime objects. Closes BerriAI#23585
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR fixes a PostgreSQL/Prisma timestamp compatibility error in Key observations:
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/db/tool_registry_writer.py | Partial fix for PostgreSQL timestamp compatibility: batch_upsert_tools is fixed, but update_tool_policy still passes a raw timezone-aware datetime object to Prisma, leaving the same bug unresolved in that code path. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[batch_upsert_tools called] --> B["now = datetime.now(timezone.utc).isoformat() ✅ FIXED"]
B --> C[Prisma upsert with ISO string timestamp]
C --> D[PostgreSQL accepts timestamp string]
E[update_tool_policy called] --> F["now = datetime.now(timezone.utc) ❌ NOT FIXED"]
F --> G[Prisma upsert with datetime object]
G --> H[PostgreSQL type mismatch error]
Comments Outside Diff (1)
-
litellm/proxy/db/tool_registry_writer.py, line 174 (link)Incomplete fix — same timestamp issue in
update_tool_policyThe
batch_upsert_toolsfunction is fixed, but theupdate_tool_policyfunction (lines 174–188) still uses a baredatetime.now(timezone.utc)object forcreated_atandupdated_at. If the root cause is that PostgreSQL/Prisma rejects timezone-awaredatetimeobjects directly, this function will trigger the same error when called. The fix should be applied consistently throughout the file.
Last reviewed commit: cac533c
Fixes timestamp type mismatch error in
tool_registry_writer.pywhen inserting intoLiteLLM_ToolTable. PostgreSQL expects timestamp format, not timezone-aware datetime objects.Closes #23585