Repository navigation
fix(api): honor include_parsing_status in List Datasets endpoint - #16913
yuzhichang merged 5 commits into
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthrough
ChangesDataset Parsing Status
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related PRs
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
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
api/apps/services/dataset_api_service.pytest/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py
|
Can someone take a look when you have a chance? |
1 similar comment
|
Can someone take a look when you have a chance? |
62656b1 to
af5cc86
Compare
…-status-in-list-datasets
|
CodeRabbit thread resolved (deferring the tighten-on-include_parsing_status to a follow-up is fine). CI green. |
1 similar comment
|
CodeRabbit thread resolved (deferring the tighten-on-include_parsing_status to a follow-up is fine). CI green. |
|
CodeRabbit thread resolved (deferring the tighten-on-include_parsing_status to a follow-up). Standing by for a maintainer pass. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Fixes #16855.
Problem
ListDatasetReqdeclaresinclude_parsing_status: bool = Falsebutdataset_api_service.list_datasetsignored the flag, so callers passinginclude_parsing_status=truegotnullfor 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 fordescin 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_helpertest_list_datasets_with_include_parsing_status_true_attaches_countstest_list_datasets_with_include_parsing_status_string_truetest_list_datasets_with_include_parsing_status_false_skips_helpertest_list_datasets_with_include_parsing_status_string_false_skips_helpertest_list_datasets_with_empty_kb_list_skips_helper_even_when_flag_truetest_list_datasets_with_include_parsing_status_missing_kb_gets_empty_dictFiles 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_statusfield in the OpenAPI response schema atapi/apps/restful_apis/dataset_api.pyso Swagger / generated clients document it.