Repository navigation
A client reads a document back by the external_id it pushed it under - #1280
Conversation
Signed-off-by: Bogdan Szabo <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
58c0385 to
5fd5fbc
Compare
|
Thank you, WaylandYang, for the reviews and merges of #1264, #1318, #1319 and #1320, and for the kind words on them. Thank you too for agreeing the shape on #1276, which made this rework simple to scope. I've rebased this onto
|
|
Hi @WaylandYang, a gentle ping whenever you have a moment, with no rush at all. This one is rebased on today's |
Sync upstream dev into re-dev (2026-10-21): deeplethe#1349, deeplethe#1280, deeplethe#1331, deeplethe#1326, deeplethe#1328
Part of #1276, in the shape agreed there. Related: #1268 / #1275 (a declared
external_idstays the document's identity), #1262 and #1264 (token reads).What happened
A client that pushes to an
apiorstatementssource names each document by its ownexternal_id, but could only read it back by Utopia's document id, which it never kept. So it could check what landed only by searching for its own text.What changed
GET /kbs/{id}/sources/{source_id}/documents/by-external-id?external_id=…returns the document's metadata, its currentversion, its text ascontent, andversions(the list/versionsgives; older text throughGET /documents/{id}/content?version=N). The id is a query parameter because ids can contain/.kb_idsreach the base, throughrequire_reader_kb. The source's push key is not accepted, so a leaked key stays push-only.source_in_kb, nowpub(crate)) and beapiorstatements; otherwise 404.pushed_key, which the API push, the statements push and this read all call, so the three cannot drift apart.read_retained, which both routes call. It takes the caller's conditions on the row, so the source, key, trash and tombstone checks are judged on the row it locks, not on the one read before the lock. A document in the trash, a tombstoned id and one never pushed are all 404; purge clearsexternal_key, so a purged id is 404 as well.Docs:
web/src/docs/ingest.mdgains "Reading a pushed document back". 0052 gets a dated revision note instead of an edit to its decision. In 0014 the route is a short paragraph inside decision 7, next to the six graph reads, and decision 7's revision line now reads "2026-10-19: the graph overview and neighbourhood join them, and so does reading a pushed document back by itsexternal_id(#1276)."access-and-audit.mdand theSessionOrTokencomment inauth.rsname the route.Tests
In
api::sources_statements_tests, on its existing fixture:[1, 2], and a token limited to another base gets 404;Rebased on
devatfa6cd6cc. Run against Postgres withUTOPIA_TEST_REQUIRE_DB=1:cargo fmt --all -- --checkandcargo clippy -p utopia-server --all-targets -- -D warningsare clean, andcargo test -p utopia-servergives 688 passed, 0 failed, 2 ignored (the two live-network tests).🤖 Generated with Claude Code