[Bug] DatasetSegmentListApi in Service API returns invalid has_more and metadata when page or limit is non-positive

オープン 初心者向け
#42,446 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
api, backend

調査の方向性

api/controllers/service_api/dataset/segment.py の DatasetSegmentListApi.get から始め、api/controllers/service_api/app/annotation.py の AnnotationListApi とページネーション処理を比較します。limit=0 および 0 以下の page 値でリクエストを再現し、返されるデータと has_more、limit、page のメタデータが正規化されたページネーション値を使用していることを確認します。

索引モデルが issue の本文から書いたものです。

説明

🐞 bug
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

1.0.0-dev (main)

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce
  1. Inspect DatasetSegmentListApi.get in api/controllers/service_api/dataset/segment.py.
  2. Notice page and limit = min(args.limit, 100) are read from query arguments without calling clamp_pagination(args.page, args.limit, 100).
  3. Send a GET request to /v1/datasets/{dataset_id}/documents/{document_id}/segments?limit=0 using a valid dataset API key for a document with existing chunks.
  4. Inspect the returned JSON response payload.
✔️ Expected Behavior

DatasetSegmentListApi.get should normalize page and limit using clamp_pagination(args.page, args.limit, 100) (matching sibling endpoints like AnnotationListApi in api/controllers/service_api/app/annotation.py), ensuring effective_page and effective_limit are used consistently for query execution and response metadata fields (has_more, limit, page).

❌ Actual Behavior

Unclamped variables are passed directly to the response metadata:

  • response["has_more"] evaluates 0 * 0 < total, returning true for any non-empty document (total > 0).
  • API consumers using has_more for pagination get trapped in infinite request loops.
  • response["limit"] and response["page"] return unclamped non-positive numbers (0 or negative integers), contradicting the actual returned data array.
主要言語
TypeScript
スター
157k
フォーク
24.7k
平均マージ
22時間 32分
マージ済み PR(30日)
611

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

langgenius/dify のほかの issue

langgenius/dify の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。