Repository navigation
fix(sdk): retain image IDs on chunks - #19505
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe SDK adds ChangesChunk image ID support
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The SDK now retains server-provided chunk image IDs across the supported operations, with defaults and response filtering covered by tests. No merge-blocking risk remains. 🚥 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. A rabbit checks each chunk with care Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The change is minimal and consistent with existing API behavior (image_id already emitted), and the added tests directly validate the corrected SDK behavior across all affected entry points.
Pull request overview
Fixes the Python SDK’s Chunk model so it retains the server-provided image_id field across chunk creation, listing, and retrieval, matching the documented chunk.image_id API and preventing AttributeError when consumers access it.
Changes:
- Add
image_idas a first-classChunkattribute (defaulting to"") so it is not dropped by the SDK’s response-key filtering. - Add unit tests that exercise
Document.add_chunk(),Document.list_chunks(), andRAGFlow.retrieve()against a local HTTP stub to verifyimage_idis preserved (including empty-string defaults) and unknown fields remain filtered.
File summaries
| File | Description |
|---|---|
sdk/python/ragflow_sdk/modules/chunk.py |
Adds image_id to Chunk’s known fields so it survives key-filtering and appears in to_json(). |
test/unit_test/sdk/test_chunk_image_id.py |
Adds focused tests covering image_id preservation/defaulting across SDK endpoints and continued filtering of unknown fields. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
LGTM 🚀 What the change does — Cross-check of the premise — the server really does emit What was verified
Nits (non-blocking)
Out-of-scope observations found during live verification (pre-existing, not introduced here — no action required in this PR)
|
|
@euvre Thanks for the detailed review and service verification. Addressed both non-blocking nits in 5903559:
Validation: all 8 chunk tests pass; Ruff check, format check and diff check pass. A local HTTP control probe confirmed that a wrong retrieval path received 200 from the old peer and receives 404 after this change. The separate retrieval observation remains outside this PR as suggested. Any follow-up should establish the backend-specific behavior first: the Elasticsearch/OpenSearch adapters handle missing availability fields differently from a strict equality filter. I have not independently repeated the live-service verification. |
|
LGTM 🚀 Follow-up review — re-checked after
What was verified
The fix itself follows the established one-attribute-default pattern in |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19505 +/- ##
=========================================
+ Coverage 0 37.37% +37.37%
=========================================
Files 0 54 +54
Lines 0 15375 +15375
Branches 0 125 +125
=========================================
+ Hits 0 5747 +5747
- Misses 0 9601 +9601
- Partials 0 27 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Document.add_chunk(),Document.list_chunks(), andRAGFlow.retrieve()discard theimage_idreturned by the server.Chunk.__init__removes response keys that do not have a corresponding instance attribute, andimage_idis missing from that list. Accessing the documentedchunk.image_idraisesAttributeError, even when the HTTP response contains an image reference.Initialize
image_idto an empty string so the SDK retains the returned identifier and includes it into_json(). Responses without an image field get the documented empty default.Validation
5bd80b345: 7 failed, 1 passed. Fix branch: 8 passed.git diff --checkpass for the touched Python files.The API reference already documents
image_idonChunk, and the current add/list/retrieval handlers already return it. Checked the adjacent image/audio/metadata PRs (#18889, #15766, #15868, #15732); none changes the SDK Chunk model.