Skip to content

Conversation

@cabana8471-arch
Copy link

@cabana8471-arch cabana8471-arch commented Jan 25, 2026

Problem

Several API endpoints return 500 Internal Server Error when datetime objects are present:

  • GET /agent/{project}/status
  • GET /devserver/{project}/status
  • GET /schedules/{project}/next

Error message:

TypeError: Object of type datetime is not JSON serializable

Root Cause

Pydantic response models expect strings for Optional[str] datetime fields, but the code was passing raw datetime objects from the manager classes.

Solution

Convert datetime objects to ISO 8601 strings using .isoformat() before returning in Pydantic response models:

# Before
started_at=manager.started_at,

# After
started_at=manager.started_at.isoformat() if manager.started_at else None,

Files Changed

  • 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

Testing

After this fix, all three endpoints return 200 OK with properly formatted datetime strings.

Summary by CodeRabbit

Bug Fixes

  • Standardized timestamp formatting across API responses for improved compatibility. Agent status, dev server status, and schedule endpoints now consistently return all timestamp fields (started_at, next_start, next_end) as ISO 8601-formatted strings instead of raw objects. This ensures better interoperability with client applications and standard tools that expect standardized date formats.

✏️ Tip: You can customize this high-level summary in your review settings.

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>
@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

Three API response endpoints are updated to serialize datetime fields to ISO 8601 string format instead of returning raw datetime objects. The changes affect agent status, devserver status, and scheduled run responses. No behavioral or control flow modifications.

Changes

Cohort / File(s) Summary
DateTime Serialization in API Responses
server/routers/agent.py, server/routers/devserver.py, server/routers/schedules.py
All three files convert datetime objects to ISO 8601 string format in their response payloads. Agent and devserver routes format started_at; schedules route formats next_start and next_end. Changes ensure consistent datetime serialization across API responses.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Time now flows in ISO's golden string,
No more raw datetimes, just formatted fling!
Three routers dancing, isoformat they sing,
API responses bright—a serializing spring!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: converting raw datetime objects to ISO 8601 strings for Pydantic serialization across multiple API endpoints.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant