Skip to content

An .xlsx picture below the last text row and past row 10 is uploaded but never indexed #45181

Open

Description

@wolfiesch

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

main (dca4024e57)

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

Upload an .xlsx to a knowledge base where a picture sits in a table column below the last row that has text, past row 10. For example, a sheet whose last text row is 2, with a picture anchored at C12 under an Image header:

     A          B          C
1    Question   Answer     Image
2    Q1         A1
...
12                         [picture]

api/core/rag/extractor/excel_extractor.py uploads embedded images first (_extract_images_from_sheet), then walks rows with:

for row in sheet.iter_rows(min_row=start_row, max_col=max_col_idx, values_only=False):

Without max_row, openpyxl stops at sheet.max_row. A row that holds only a picture has no cells, so it is never visited. Rows up to 10 survive only by accident: the header scan (_find_header_and_columns) calls iter_rows(max_row=10), which makes openpyxl create empty cells for rows 1 to 10 and raises max_row to 10.

✔️ Expected Behavior

Each picture-only row becomes a document with its markdown image, as it does for rows up to 10:

"Question":"Q1";"Answer":"A1";"Image":""
"Question":"";"Answer":"";"Image":"![image](.../files/<upload id>/file-preview)"

❌ Actual Behavior

Only the first line is indexed. The picture is still saved to storage with an UploadFile row, but no document references it, so it cannot be retrieved.

Found while testing #44849. A fix with a real-workbook test follows.

Activity

  1. xz567001-afk commented on Oct 31, 2026

    @xz567001-afk

    One boundary to preserve in the follow-up workbook test: _extract_images_from_sheet() only returns anchors after the header and in recognized header columns. If row coverage is extended, deriving its extent from the returned image map rather than every worksheet drawing preserves those exclusions. Pairing the C12 inclusion case with above-header and unrecognized-column exclusion cases would help keep that behavior. This is a static check at the reported revision; I haven't run the workbook test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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