Skip to content

fix(api): GET /documents crashes with 500 when created_at column is NULL in legacy DB rows #294

Closed

Description

@piyushmakhija28

Summary

_to_document_schema in backend/app/api/documents.py at line ~136 passes record.created_at (which is str | None in DocumentRecord) to Document(created_at=...) where created_at: str is non-optional in the Pydantic schema. When the DB row has created_at=NULL (e.g. legacy rows from migration 001 before onupdate was added), Pydantic raises ValidationError and the GET /documents endpoint returns unhandled HTTP 500.

Fix

backend/app/api/documents.py: either make Document.created_at optional (str | None = None) or coerce None to an empty string / ISO timestamp default in _to_document_schema.

Impact

Any tenant that has documents created before the created_at column was added (migration 001 rows without onupdate DEFAULT) gets HTTP 500 on GET /documents.

Activity

  1. piyushmakhija28 commented on Jun 21, 2026

    @piyushmakhija28
    ContributorAuthor

    Fixed in PR #280 (Sprint R3/R4: fix(sprint-r3): root-cause fixes for all 39 bugs from code review round 3 + Sprint R4 round 4)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcode-reviewFound via automated code reviewpriority: mediumFunctional error with workaround

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions