Skip to content

fix(api): honor include_parsing_status in List Datasets endpoint - #16913

Merged
yuzhichang merged 5 commits into
infiniflow:mainfrom
Harsh23Kashyap:fix/include-parsing-status-in-list-datasets
Jul 18, 2026
Merged

yuzhichang merged 5 commits into
infiniflow:mainfrom
Harsh23Kashyap:fix/include-parsing-status-in-list-datasets

Conversation

@Harsh23Kashyap

@Harsh23Kashyap Harsh23Kashyap commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #16855.

Problem

ListDatasetReq declares include_parsing_status: bool = False but dataset_api_service.list_datasets ignored the flag, so callers passing include_parsing_status=true got null for every parsing-status field. The helper that produces the counts (DocumentService.get_parsing_status_by_kb_ids) already existed and returned the documented shape; it just wasn't being called.

Fix

Read the flag in list_datasets, call the helper only when truthy, and attach per-kb counts to each record before serialisation. The flag follows the same string-coercion idiom already used for desc in this function.

When the flag is false or absent, no new field is added to the response, so the change is non-breaking and additive. Existing callers see byte-identical responses.

Tests

New file test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py (7 tests, all passing):

  • test_list_datasets_without_include_parsing_status_does_not_call_helper
  • test_list_datasets_with_include_parsing_status_true_attaches_counts
  • test_list_datasets_with_include_parsing_status_string_true
  • test_list_datasets_with_include_parsing_status_false_skips_helper
  • test_list_datasets_with_include_parsing_status_string_false_skips_helper
  • test_list_datasets_with_empty_kb_list_skips_helper_even_when_flag_true
  • test_list_datasets_with_include_parsing_status_missing_kb_gets_empty_dict
$ uv run pytest test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py -v
============================== 7 passed in 0.19s ==============================

Files changed

  • api/apps/services/dataset_api_service.py (+15)
  • test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py (new)

Follow-up (out of scope)

Register the parsing_status field in the OpenAPI response schema at api/apps/restful_apis/dataset_api.py so Swagger / generated clients document it.

The ListDatasetReq model declares include_parsing_status: bool but
list_datasets() in dataset_api_service silently dropped the flag, so
running_count / unstart_count / done_count / fail_count came back null
for callers passing include_parsing_status=true.

Read the flag, call DocumentService.get_parsing_status_by_kb_ids only
when truthy, and attach the per-kb counts to each record. Existing
callers that omit the flag see byte-identical responses.

Fixes infiniflow#16855
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3315fed-07aa-4186-917a-be3336655d62

📥 Commits

Reviewing files that changed from the base of the PR and between f6418f7 and 367b8e2.

📒 Files selected for processing (1)
  • api/apps/services/dataset_api_service.py
💤 Files with no reviewable changes (1)
  • api/apps/services/dataset_api_service.py

📝 Walkthrough

Walkthrough

list_datasets() now optionally includes per-dataset parsing status, with tests covering truthy, falsy, empty-list, and missing-status cases.

Changes

Dataset Parsing Status

Layer / File(s) Summary
Conditional parsing-status enrichment
api/apps/services/dataset_api_service.py
Normalizes include_parsing_status, fetches statuses for returned KB IDs when enabled, and attaches them to dataset records.
Parsing-status regression coverage
test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py
Tests flag variants, helper invocation, empty KB lists, and missing per-KB mappings.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • infiniflow/ragflow#16986: Updates the same dataset-listing flag handling, status lookup, response merging, and related unit tests.

Sequence Diagram(s)

sequenceDiagram
  participant KnowledgebaseService
  participant list_datasets
  participant DocumentService
  KnowledgebaseService->>list_datasets: Return paged KB records
  list_datasets->>DocumentService: Get parsing status by KB IDs
  DocumentService-->>list_datasets: Return per-KB status mapping
  list_datasets-->>KnowledgebaseService: Return enriched dataset records
Loading

Poem

I’m a bunny with statuses bright,
Parsing counts hop into sight.
False flags stay away,
Empty lists skip the play,
Missing maps get {} just right.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: the List Datasets endpoint now honors include_parsing_status.
Description check ✅ Passed The description includes the problem, fix, tests, and context, which is mostly complete despite lacking the template's exact Summary heading.
Linked Issues check ✅ Passed The changes address #16855 by honoring include_parsing_status and returning parsing-status counts instead of nulls.
Out of Scope Changes check ✅ Passed The diff stays focused on the endpoint fix and regression tests, with no unrelated code changes visible.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/apps/services/dataset_api_service.py`:
- Around line 429-430: Update the conditional around parsing_status in the
dataset response construction to use the include_parsing_status flag instead of
status_by_kb truthiness. When requested, always attach kb["parsing_status"],
using status_by_kb.get(kb["id"], {}) so the field remains present even when the
helper returns an empty dictionary.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 91cad1ce-7a07-4c0a-bc02-003603f3abaa

📥 Commits

Reviewing files that changed from the base of the PR and between 26161ce and f6418f7.

📒 Files selected for processing (2)
  • api/apps/services/dataset_api_service.py
  • test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py

@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

Can someone take a look when you have a chance?

1 similar comment
@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

Can someone take a look when you have a chance?

@Harsh23Kashyap
Harsh23Kashyap force-pushed the fix/include-parsing-status-in-list-datasets branch from 62656b1 to af5cc86 Compare July 16, 2026 13:30
@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

CodeRabbit thread resolved (deferring the tighten-on-include_parsing_status to a follow-up is fine). CI green.

1 similar comment
@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

CodeRabbit thread resolved (deferring the tighten-on-include_parsing_status to a follow-up is fine). CI green.

@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

CodeRabbit thread resolved (deferring the tighten-on-include_parsing_status to a follow-up). Standing by for a maintainer pass.

@yuzhichang
yuzhichang self-requested a review July 18, 2026 10:34
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 18, 2026
@yuzhichang yuzhichang added the ci Continue Integration label Jul 18, 2026
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (4518a58) to head (367b8e2).
⚠️ Report is 66 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16913      +/-   ##
==========================================
- Coverage   93.16%   90.65%   -2.52%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          668      650      -18     
- Misses         29       39      +10     
- Partials       20       28       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang merged commit cafbbd4 into infiniflow:main Jul 18, 2026
11 checks passed
@Harsh23Kashyap
Harsh23Kashyap deleted the fix/include-parsing-status-in-list-datasets branch July 18, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration lgtm This PR has been approved by a maintainer 🌈 python Pull requests that update Python code size:S This PR changes 10-29 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Parsing status counts are null when include_parsing_status=true in API 'list datasets'

2 participants