mirror of
https://github.com/leonvanzyl/autocoder.git
synced 2026-02-03 07:33:37 +00:00
fix: Pydantic datetime serialization for API endpoints
Problem:
Several API endpoints return 500 Internal Server Error because datetime
objects are not serializable by Pydantic. The error occurs when:
- GET /agent/{project}/status
- GET /devserver/{project}/status
- GET /schedules/{project}/next
Root cause:
Pydantic models expect strings for Optional datetime fields, but the code
was passing raw datetime objects.
Solution:
Convert datetime objects to ISO 8601 strings using .isoformat() before
returning in Pydantic response models.
Changes:
- server/routers/agent.py: Fix started_at serialization
- server/routers/devserver.py: Fix started_at serialization
- server/routers/schedules.py: Fix next_start/next_end serialization
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -256,8 +256,8 @@ async def get_next_scheduled_run(project_name: str):
|
||||
|
||||
return NextRunResponse(
|
||||
has_schedules=True,
|
||||
next_start=next_start if active_count == 0 else None,
|
||||
next_end=latest_end,
|
||||
next_start=next_start.isoformat() if (active_count == 0 and next_start) else None,
|
||||
next_end=latest_end.isoformat() if latest_end else None,
|
||||
is_currently_running=active_count > 0,
|
||||
active_schedule_count=active_count,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user