Skip to content

Deletion blocked when Knowhere archive returns document not found #131

Description

@suguanYang

Summary

Deleting a Notebook source can fail permanently when the local source row still has a knowhereDocumentId, but the upstream Knowhere document has already been deleted or archived.

Observed on staging for source 887294db-a793-4522-9254-45808dfb77d0.

Evidence

Vercel staging log at 2026-07-05 22:29:55 CST:

PATCH /api/sources/887294db-a793-4522-9254-45808dfb77d0 -> 500
knowhere: documents.archive("doc_6dda64c37f74")
knowhere: documents.archive failed: Document not found

The route aborts before the Notebook local row is soft-deleted.

Code Path

src/domains/sources/route-archive.ts archives the Knowhere document before calling sourceService.softDelete(...):

client.documents.archive(source.knowhereDocumentId)
sourceService.softDelete(workspace.id, input.sourceId)

Expected Behavior

If Knowhere returns a not-found response during archive, Notebook should still soft-delete/hide the local source row. Upstream absence means there is nothing left to archive, not that the user-visible row must remain undeletable.

Suggested Fix

Treat Knowhere NotFoundError / 404 from documents.archive as archive success for local deletion purposes. Preserve normal failure behavior for other errors.

Verification

Add a route-service test where documents.archive throws Knowhere not-found and assert the local softDelete still runs and the response is success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions