Skip to content

Conversation

@agamm
Copy link
Owner

@agamm agamm commented Aug 19, 2025

Summary

  • Fixes JSON serialization failure when Pydantic models contain date fields
  • Updates JobResult.to_dict() to use model_dump(mode='json') for proper serialization
  • Adds comprehensive unit tests for date field serialization scenarios

Problem

When using Pydantic models with date fields as response_model, the library would fail to save results to JSON files because Python's json.dump() cannot serialize date objects directly. This caused truncated output files and error messages like "Object of type date is not JSON serializable".

Solution

Changed model_dump() to model_dump(mode='json') in JobResult.to_dict(), which ensures all fields are JSON-serializable (dates become ISO format strings).

Test Plan

  • Added unit tests for date field serialization
  • Verified fix works with both Pydantic models and dict responses
  • All existing tests continue to pass

No breaking changes

- Update JobResult.to_dict() to use model_dump(mode='json') for proper date serialization
- Add comprehensive unit tests for date field serialization
- Resolves truncated JSON output files when using Pydantic models with date fields

No breaking changes
@agamm agamm merged commit 542d5b9 into main Aug 19, 2025
1 check passed
@agamm agamm deleted the fix/date-obj branch August 19, 2025 20:25
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.

2 participants