Skip to content

fix(backup): serialize datetime in directories JSONB#74

Merged
max-tet merged 1 commit intomainfrom
fix/backup-json-datetime
Apr 21, 2026
Merged

fix(backup): serialize datetime in directories JSONB#74
max-tet merged 1 commit intomainfrom
fix/backup-json-datetime

Conversation

@max-tet
Copy link
Copy Markdown
Member

@max-tet max-tet commented Apr 21, 2026

Summary

  • Backup job crashed with TypeError: Object of type datetime is not JSON serializable when inserting report row.
  • Root cause: Jsonb(...) uses stdlib json.dumps, which can't serialize datetime. BackupStats.startTime/endTime inside directories are datetimes.
  • Fix: db_backups.insert now takes BackupReport directly and dumps nested BackupStats with mode="json" (ISO strings) for the JSONB column, while keeping top-level startTime/endTime as datetime for the timestamp columns.

Test plan

  • Run daily backup cron, verify row appears in backups table with correct directories JSON and valid start_time/end_time.
  • GET last backup via existing endpoint — confirm roundtrip parses back into BackupReport.

🤖 Generated with Claude Code

psycopg's Jsonb uses stdlib json.dumps which can't serialize datetime.
Pass BackupReport directly to insert() and dump nested BackupStats
with mode="json" so datetimes become ISO strings for JSONB, while
top-level timestamps stay as datetime objects for timestamp columns.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@max-tet max-tet merged commit 4a52d6a into main Apr 21, 2026
6 checks passed
@max-tet max-tet deleted the fix/backup-json-datetime branch April 21, 2026 10:19
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