Repository navigation
fix(api): return parsing-status counts at the top level of each dataset (#17595) - #17611
Conversation
…et (infiniflow#17595) The List Datasets endpoint nested the include_parsing_status counts under a "parsing_status" object, while the HTTP API and Python SDK references both document them as top-level fields of each dataset record. Signed-off-by: Anai-Guo <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe dataset listing service now returns parsing-status counts as top-level dataset fields. Regression tests cover enabled, disabled, truthy-string, falsy-string, and missing-dataset cases. ChangesDataset parsing-status response
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change only flattens documented parsing-status counts into each dataset record while preserving behavior when the option is disabled; no actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description provides clear problem context, the proposed fix, test coverage, behavior details, and an explicit note about the separate Python SDK gap. It does not use the template's exact "### Summary" heading, but it includes the required summary information and is substantially complete.
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.
🧹 Nitpick comments (1)
api/apps/services/dataset_api_service.py (1)
456-459: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd structured logging for the new parsing-status flow.
When parsing status is enabled, this code performs an extra service lookup and changes the response enrichment. Add a debug or info log with non-sensitive context, such as the dataset count and flag state. Use the module’s existing logger.
🤖 Prompt for 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. In `@api/apps/services/dataset_api_service.py` around lines 456 - 459, Add a debug or info log in the parsing-status enrichment flow around the status_by_kb lookup and kb.update, using the module’s existing logger. Include only non-sensitive context such as the dataset count and whether parsing status is enabled, while preserving the current response enrichment behavior.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@api/apps/services/dataset_api_service.py`:
- Around line 456-459: Add a debug or info log in the parsing-status enrichment
flow around the status_by_kb lookup and kb.update, using the module’s existing
logger. Include only non-sensitive context such as the dataset count and whether
parsing status is enabled, while preserving the current response enrichment
behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 26e266ec-197e-424b-be03-e4aca2d9a1f4
📒 Files selected for processing (2)
api/apps/services/dataset_api_service.pytest/unit_test/api/apps/services/test_dataset_api_service_list_datasets.py
8a735c5 to
0690b65
Compare
|
Heads-up on the conflict marker: The source-file hunk still merges cleanly — the anchor is unchanged: if status_by_kb:
kb["parsing_status"] = status_by_kb.get(kb["id"], {})The only real conflict is in the regression test. assert "parsing_status" in payload["data"][0]to I unfortunately can't force-push a rebase myself: my fork can't be synced with if status_by_kb:
# counts belong at the top level of each dataset record per the HTTP API
# and Python SDK references, not under a nested "parsing_status" object
kb.update(status_by_kb.get(kb["id"], {}))plus flipping the test assertions from |
Lynn-Inf
left a comment
There was a problem hiding this comment.
LGTM. This can be merged once conflicts are resolved and CI passes.
|
@Anai-Guo Would you please resolve the conflicts? |
|
@JinHai-CN Yes — the merge is resolved and green locally (11/11 in
assert "done_count" in payload["data"][0]Worth calling out: (2) does not show up as a conflict. Git auto-merges it cleanly, and the result is a test that asserts the nested
🤖 Generated with Claude Code |
|
@Anai-Guo The PR is conflicts with current code base. |
|
@JinHai-CN I notice this is still flagged as If @Anai-Guo pulls the diff from that branch into Concretely the conflict was at one block (line ~300 in the test file):
Resolution: keep main's new test, keep #17611's refactored If the merge bot still shows DIRTY after the fix-up, a fresh push to the same branch is usually enough to retrigger it. |
|
@JinHai-CN — I have the conflict resolved and verified locally, but I currently cannot push the merge commit: merging
With just that, the file is green: Happy to push it the moment I have the scope, or if you'd prefer, the two changes above are small enough to apply directly in the web conflict editor. |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
@Anai-Guo I just resolved the conflicts on web. Would you please help check the code, again? |
… flattening `test_list_datasets_with_include_parsing_status_true_attaches_counts` asserted `"parsing_status" in payload["data"][0]` and then, three lines later, `"parsing_status" not in by_id[kb_id]`. The first assertion was left over from the nested-dict shape this PR replaces; the counts are now merged at the top level of each record, so it can never hold. Removing it makes the test consistent with the contract the rest of the file already checks. Signed-off-by: Anai-Guo <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17611 +/- ##
===========================================
- Coverage 90.65% 39.07% -51.58%
===========================================
Files 10 54 +44
Lines 717 14911 +14194
Branches 118 117 -1
===========================================
+ Hits 650 5827 +5177
- Misses 39 9058 +9019
+ Partials 28 26 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Friendly ping @Lynn-Inf @JinHai-CN — this has been APPROVED since 2026-08-20 and the branch is still 🤖 Generated with Claude Code |
Fixes #17595.
Problem
include_parsing_status=trueon List Datasets returns the counts nested under aparsing_statusobject:{ "parsing_status": { "unstart_count": 0, "running_count": 0, "cancel_count": 0, "done_count": 1, "fail_count": 0 } }Both references document them as top-level fields of each dataset record:
docs/references/http_api_reference.md— theinclude_parsing_status=truesuccess example listsunstart_count,running_count,cancel_count,done_count,fail_countas siblings ofid/name/chunk_count. That example predates fix(api): honor include_parsing_status in List Datasets endpoint #16913 (it is already there at6e82e27, 2026-06-29).docs/references/python_api_reference.md— "eachDataSetobject will include the following additional attributes", with the exampleprint(dataset.done_count, dataset.fail_count, dataset.running_count).#16913 (which fixed #16855) wired the flag up correctly but attached the helper's result as a sub-object, so the shipped shape does not match the contract it was implementing — its own description says the helper "already returned the documented shape".
Fix
Merge the counts into the record instead of nesting them:
remap_dictionary_keyspasses unknown keys through untouched, so the five count fields land at the top level exactly as documented. Behaviour when the flag is absent/false is unchanged — no new keys are added.Tests
test/unit_test/api/apps/services/test_dataset_api_service_list_datasets.pywas added by #16913 and asserted the nested shape, so its expectations move to the documented one. The mock-interaction assertions (helper called once with the kb ids / not called at all, string-coercion of the flag, empty page) are untouched; only the response-shape assertions changed, and the "no counts" checks are now stricter — a shared_assert_no_counts()helper asserts that neitherparsing_statusnor any of the five count fields appear.Against unmodified
main, the three shape tests fail (test_..._true_attaches_counts,test_..._string_true,test_..._missing_kb_gets_no_counts) and the other four pass, so the suite tracks the fix rather than the implementation.Note (not addressed here)
The Python SDK's
RAGFlow.list_datasets()does not acceptinclude_parsing_statusat all, andDataSet.__init__drops response keys that are not already attributes — sodataset.done_countfrom the SDK reference cannot work even with this fix. That is a separate gap insdk/python; happy to follow up in another PR if you'd like it closed too.🤖 Generated with Claude Code