Repository navigation
fix: retain a version ledger for uploaded originals - #1204
Merged
Merged
Conversation
…essing job together Signed-off-by: Virtue039 <virtue039@qq.com>
WaylandYang
approved these changes
Oct 13, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thank you for finding this. I confirmed it on a local rc9 database: three uploaded documents, none with a version row, and the content route answers 500 for each.
The change is right for multipart upload and its tests pass here on a fresh database. One path is still open, the JSON push (POST /kbs/{id}/ingest, through documents::create), which writes no version either; it is small, so we will close it in a follow-up of our own.
Merging. Thanks again.
WaylandYang
added a commit
that referenced
this pull request
Oct 13, 2026
…back (#1211) #1204 gave multipart uploads their first version row. The JSON push (POST /kbs/{id}/ingest) creates its document through documents::create, which still wrote none, so GET /documents/{id}/content answered 500 for every pushed document. The document and version 1 are now written in one transaction there too. Documents pushed before this are repaired by migration 0111. Signed-off-by: Wayland Yang <wayland0916@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful multipart uploads could not serve their original content: upload inserted a document without a
document_versionsrow, whileGET /documents/{id}/contentrequires the current digest in that ledger. Both real-model acceptance runs reproduced this for every uploaded document (16 total), although the original blobs were retained.Uploads now commit the document, version 1 and processing job in one transaction, using the existing sync ingestion transaction helper while preserving upload date provenance. Reuploading a soft-deleted original restores the same document and version and queues processing atomically. Queue failure rolls back both new creation and restoration; active duplicates still skip without queuing another job.
Migration 0111 records the current digest, size and document date for retained documents with no version ledger. Its ingestion timestamp is the repair time: it does not reconstruct missing historical revisions or original ingestion times. Existing ledgers and purged documents are left untouched. The CLI schema version is bumped to 100, matching the migration file count. This repairs the existing content API contract without changing its response shape.
Validation:
versions.len(): 0 instead of 1) and passes with this change.UTOPIA_TEST_REQUIRE_DB=1andUTOPIA_TEST_REQUIRE_PDFTOTEXT=1; all new tests ran, including queue rollback, restoration and idempotent migration repair.cargo fmt --all --check, locked workspace/all-target Clippy with-D warnings, locked workspace tests and server build passed.The separate negative-case design PR #1203 and the observed alignment, literal extraction and end-date failures remain outside this bugfix. Latest main/dev migration numbers were checked before submission.