Parent-child full-doc mode raises IndexError when extraction yields zero documents

Open Beginner friendly
#45,272 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

@simpleqt is already working on this.

Since Nov 1, 2026.

  • #45273 by @simpleqt — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in api/core/rag/index_processor/processor/parent_child_index_processor.py, in transform(), at the FULL_DOC branch near line 119 where documents[0].metadata is read without a check. Compare with the zero-chunk guard that PR #45089 added to the QA processor, and with how paragraph mode returns no chunks for empty input. Done when transform([]) in full-doc mode returns no chunks and does not raise, and the parent-child processor tests pass.

Written by the indexing model from the issue text.

Description

1.18.0
Self Checks
  • This is a bug report, not a feature request
  • I have searched the existing issues
Description

ParentChildIndexProcessor.transform() crashes with IndexError: list index out of range when parent mode is FULL_DOC and extraction yields zero documents (e.g. an empty Notion page or an empty URL fetch - both legitimately return []):

# api/core/rag/index_processor/processor/parent_child_index_processor.py, FULL_DOC branch
document = Document(page_content=page_content, metadata=documents[0].metadata)  # line 119, unguarded

Impact: the indexing-estimate endpoint fails with a 500-style "list index out of range", and real indexing marks the document failed. Paragraph mode handles the same input correctly by producing zero chunks; only the full-doc branch is affected.

This is the exact sibling of #45087 (zero QA chunks -> IndexError -> HTTP 500), which was fixed for the QA processor in #45089 - the parent-child full-doc branch was missed.

Reproduction
  1. Create a knowledge base with a parent-child indexing technique in full-doc parent mode.
  2. Add a source that extracts zero documents (empty Notion page / URL that returns empty content).
  3. Estimate or index: ParentChildIndexProcessor.transform([], ...) raises IndexError at parent_child_index_processor.py:119.

Expected: no chunks, same as paragraph mode. Actual: IndexError.

Environment
  • Dify main @ a79e2116
  • OS: any (not platform-specific)
Dominant language
Python
Stars
160k
Forks
25.4k
Avg merge
1d 1h
Merged PRs (30d)
608

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from langgenius/dify

All issues in langgenius/dify

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.