Batch call to upload document interface resulted in incorrect document numbering, with duplicate numbering. #6055

Closed
opened 2026-02-21 18:13:52 -05:00 by yindo · 6 comments
Owner

Originally created by @glacierck on GitHub (Oct 12, 2024).

Originally assigned to: @JohnJyong on GitHub.

Self Checks

  • 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 (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.9.1

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

  1. Call 'create_by_file' to upload ten documents

  2. Check the upload results on the web

image

✔️ Expected Behavior

Obtain documents from 1 to 10

Actual Behavior

Number 4 is repeated.

ps.Is the serial number meaningful? Why is it necessary to assign a fixed serial number without ensuring uniqueness?

Originally created by @glacierck on GitHub (Oct 12, 2024). Originally assigned to: @JohnJyong on GitHub. ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.9.1 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce 1. Call 'create_by_file' to upload ten documents 2. Check the upload results on the web ![image](https://github.com/user-attachments/assets/740bce0d-e460-410f-9da4-425aec195e3b) ### ✔️ Expected Behavior Obtain documents from 1 to 10 ### ❌ Actual Behavior Number 4 is repeated. ps.Is the serial number meaningful? Why is it necessary to assign a fixed serial number without ensuring uniqueness?
yindo added the 🐞 bug label 2026-02-21 18:13:52 -05:00
yindo closed this issue 2026-02-21 18:13:52 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 12, 2024):

The issue of duplicate document numbering during batch uploads might be related to how the create_by_file function assigns document positions. Currently, there isn't a specific mechanism documented to ensure unique numbering for uploaded documents, which could lead to duplicates [1].

The system uses UUIDs to ensure unique document identifiers, but this doesn't apply to the visible numbering or positions [2]. The numbering might be more for display purposes rather than a critical identifier.

To address this, you might consider implementing a custom logic to ensure unique numbering or check if there's a bug in the current implementation that needs fixing.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 12, 2024): <!-- Answer --> The issue of duplicate document numbering during batch uploads might be related to how the `create_by_file` function assigns document positions. Currently, there isn't a specific mechanism documented to ensure unique numbering for uploaded documents, which could lead to duplicates <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/knowledge-base/maintain-dataset-via-api.md)</sup>. The system uses UUIDs to ensure unique document identifiers, but this doesn't apply to the visible numbering or positions <sup>[[2]](https://github.com/langgenius/dify/blob/main/api/migrations/versions/64b051264f32_init.py)</sup>. The numbering might be more for display purposes rather than a critical identifier. To address this, you might consider implementing a custom logic to ensure unique numbering or check if there's a bug in the current implementation that needs fixing. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@glacierck commented on GitHub (Oct 12, 2024):

@dosu It is suggested to cancel the assignment of sequence numbers and switch to dynamic rendering by the front-end.

@glacierck commented on GitHub (Oct 12, 2024): @dosu It is suggested to cancel the assignment of sequence numbers and switch to dynamic rendering by the front-end.
Author
Owner

@dosubot[bot] commented on GitHub (Oct 12, 2024):

Switching to dynamic rendering on the front-end is a great idea. This approach can help avoid issues with duplicate numbering by generating the sequence dynamically based on the current dataset. It would ensure that the numbering is always unique and consistent with the displayed data. If you need guidance on implementing this change, feel free to ask!

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 12, 2024): <!-- Answer --> Switching to dynamic rendering on the front-end is a great idea. This approach can help avoid issues with duplicate numbering by generating the sequence dynamically based on the current dataset. It would ensure that the numbering is always unique and consistent with the displayed data. If you need guidance on implementing this change, feel free to ask! <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@glacierck commented on GitHub (Oct 12, 2024):

@dosu Additionally, information on the total number of documents should also be provided on the document list view.

@glacierck commented on GitHub (Oct 12, 2024): @dosu Additionally, information on the total number of documents should also be provided on the document list view.
Author
Owner

@dosubot[bot] commented on GitHub (Oct 12, 2024):

To display the total number of documents in the document list view, you can use the total property from the documentsRes object. Here's a quick example:

const DocumentList: FC<IDocumentListProps> = ({ documents = [], datasetId }) => {
  const { data: documentsRes } = useSWR(
    {
      action: 'fetchDocuments',
      datasetId,
    },
    apiParams => fetchDocuments(omit(apiParams, 'action')),
  )

  // Display the total number of documents
  const totalDocuments = documentsRes?.total || 0

  return (
    <div>
      <div>Total Documents: {totalDocuments}</div>
      {/* Rest of the component code */}
    </div>
  )
}

This code snippet uses the total property from documentsRes to display the total number of documents [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 12, 2024): <!-- Answer --> To display the total number of documents in the document list view, you can use the `total` property from the `documentsRes` object. Here's a quick example: ```tsx const DocumentList: FC<IDocumentListProps> = ({ documents = [], datasetId }) => { const { data: documentsRes } = useSWR( { action: 'fetchDocuments', datasetId, }, apiParams => fetchDocuments(omit(apiParams, 'action')), ) // Display the total number of documents const totalDocuments = documentsRes?.total || 0 return ( <div> <div>Total Documents: {totalDocuments}</div> {/* Rest of the component code */} </div> ) } ``` This code snippet uses the `total` property from `documentsRes` to display the total number of documents <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/datasets/documents/list.tsx)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/web/app/components/datasets/documents/index.tsx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@Blubiubiu commented on GitHub (Oct 14, 2024):

@dosu Additionally, information on the total number of documents should also be provided on the document list view.此外,还应在文档列表视图中提供有关文档总数的信息。

I have not been able to reproduce the issue with duplicate indices. Could you provide more detailed steps to reproduce the problem? The changes for counting the total have been submitted in a PR #9321

@Blubiubiu commented on GitHub (Oct 14, 2024): > @dosu Additionally, information on the total number of documents should also be provided on the document list view.此外,还应在文档列表视图中提供有关文档总数的信息。 I have not been able to reproduce the issue with duplicate indices. Could you provide more detailed steps to reproduce the problem? The changes for counting the total have been submitted in a PR #9321
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6055