fix: Pydantic datetime serialization for API endpoints#97
Conversation
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>
📝 WalkthroughWalkthroughThree 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
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
|
Thanks |
…on cycles - Modified _run_dependency_health_check() to return False when cycles are detected - Modified run_loop() to check health check result and exit early on cycles - Added comprehensive test suite (13 tests in tests/test_feature_97_cycle_blocks_startup.py) - Added verification script (tests/verify_feature_97.py) - Updated Feature AutoForgeAI#95 tests to expect blocking behavior on cycles Verification steps implemented: 1. Insert features A -> B -> A into database - PASS 2. Attempt to start the orchestrator - PASS (returns False) 3. Verify startup is blocked with clear error message - PASS 4. Verify error message includes the cycle path: [A, B, A] - PASS 5. Verify error message instructs user to remove one dependency - PASS Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…atetime-serialization fix: Pydantic datetime serialization for API endpoints
Problem
Several API endpoints return 500 Internal Server Error when datetime objects are present:
GET /agent/{project}/statusGET /devserver/{project}/statusGET /schedules/{project}/nextError message:
Root Cause
Pydantic response models expect strings for
Optional[str]datetime fields, but the code was passing rawdatetimeobjects from the manager classes.Solution
Convert datetime objects to ISO 8601 strings using
.isoformat()before returning in Pydantic response models:Files Changed
server/routers/agent.py- Fixstarted_atserializationserver/routers/devserver.py- Fixstarted_atserializationserver/routers/schedules.py- Fixnext_start/next_endserializationTesting
After this fix, all three endpoints return 200 OK with properly formatted datetime strings.
Summary by CodeRabbit
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.