Skip to content

fix(knowledge): reject empty document extraction - #19177

Merged
eeee0717 merged 1 commit into
CherryHQ:mainfrom
userInner:fix/empty-knowledge-document-status
Aug 28, 2026
Merged

fix(knowledge): reject empty document extraction#19177
eeee0717 merged 1 commit into
CherryHQ:mainfrom
userInner:fix/empty-knowledge-document-status

Conversation

@userInner

Copy link
Copy Markdown
Contributor

Branch strategy

  • Active development targets main.

What this PR does

Before this PR:

Knowledge items whose reader or chunker produced no indexable text were rebuilt with an empty material and marked as completed. Scanned or image-only PDFs therefore appeared ready even though their content and chunks were empty.

After this PR:

Indexing rejects zero-chunk extraction results before embedding or material replacement. The existing job settlement path records a clear failure reason, so the item is shown as failed and remains available for reindexing after OCR or document-processing settings are corrected.

Fixes #19095

Why we need it and why it was done in this way

The zero-chunk boundary is the first shared point at which every reader result has been normalized and proven unusable for both vector and lexical retrieval. Rejecting there prevents paid embedding calls and avoids replacing a material with an empty index while reusing the existing failed-status, tooltip, and reindex behavior.

The following tradeoffs were made:

An empty extraction is treated as a failed indexing attempt instead of a successful empty document. This makes the failure visible but requires users to correct the source or processing configuration before reindexing.

The following alternatives were considered:

  • Keeping the completed status and relying on a log warning was rejected because users cannot distinguish an empty extraction from a searchable item in the UI.
  • Adding automatic OCR fallback was not included because processor selection and OCR configuration are separate concerns and may involve external services or user costs.

Links to places where the discussion took place: #19095

Breaking changes

None.

If this PR introduces breaking changes, please describe the changes and the impact on users.

Special notes for your reviewer

Regression coverage includes readers returning no documents and whitespace-only documents. It also verifies that empty results never enter embedding or material replacement and that job settlement persists the actionable failure reason.

Checklist

This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.

Release note

Knowledge files that produce no indexable text now show a clear failed status instead of appearing ready with empty content and chunks.

Signed-off-by: userInner <1239989762@qq.com>
@userInner
userInner requested a review from eeee0717 as a code owner August 22, 2026 06:22

@cherry-ai-bot cherry-ai-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cherry Review · 通过

1 warning
逐条见行内评论。

@@ -94,14 +97,15 @@ export function createIndexDocumentsJobHandler(
const documents = await readItemDocuments(ctx, readableItem)
const chunked = await chunkItemDocuments(base, documents, ctx.signal)
if (chunked.chunks.length === 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议修复:Authoritative Knowledge workflow documentation still describes zero-chunk indexing as successful completion, contradicting the changed handler's failure behavior.

inv_9f9316ad75d110ea#c0

@eeee0717
eeee0717 merged commit 204453a into CherryHQ:main Aug 28, 2026
24 checks passed
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.

[Bug]: 知识库中扫描版 / 无文字层 PDF 状态显示「就绪」,但 Chunks 与正文均为空,且无任何提示

2 participants