Repository navigation
Refactor: Change update doc from PUT to patch - #14067
Conversation
|
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 (3)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughStandardizes document update requests to use HTTP PATCH instead of PUT across server, SDKs, admin client, tests, and web service; no other request payloads or response handling logic were modified. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
f95599b to
fcb8752
Compare
fcb8752 to
547be28
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@api/apps/restful_apis/document_api.py`:
- Line 35: The route decorator for the document update endpoint now only accepts
PATCH which will 405 clients still sending PUT; update the route on the manager
for the "/datasets/<dataset_id>/documents/<document_id>" endpoint to accept both
methods (e.g., include "PUT" alongside "PATCH") or add a second route mapping
PUT to the same handler (the function handling the manager.route decorator for
that path) and ensure the handler distinguishes between PATCH (partial update)
and PUT (full replace) semantics before returning.
🪄 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: a59dce4a-7ab1-44c1-a692-1e565feefe95
📒 Files selected for processing (5)
admin/client/ragflow_client.pyapi/apps/restful_apis/document_api.pysdk/python/ragflow_sdk/modules/document.pytest/testcases/test_http_api/common.pyweb/src/services/knowledge-service.ts
| ) | ||
|
|
||
| @manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["PUT"]) # noqa: F821 | ||
| @manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["PATCH"]) # noqa: F821 |
There was a problem hiding this comment.
Potential API break: removing PUT support may 405 existing clients.
Line [35] changes a public update route to PATCH-only. If any external integration still sends PUT, this becomes a hard break.
💡 Transitional compatibility option
-@manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["PATCH"]) # noqa: F821
+@manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["PATCH", "PUT"]) # noqa: F821📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["PATCH"]) # noqa: F821 | |
| `@manager.route`("/datasets/<dataset_id>/documents/<document_id>", methods=["PATCH", "PUT"]) # noqa: F821 |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@api/apps/restful_apis/document_api.py` at line 35, The route decorator for
the document update endpoint now only accepts PATCH which will 405 clients still
sending PUT; update the route on the manager for the
"/datasets/<dataset_id>/documents/<document_id>" endpoint to accept both methods
(e.g., include "PUT" alongside "PATCH") or add a second route mapping PUT to the
same handler (the function handling the manager.route decorator for that path)
and ensure the handler distinguishes between PATCH (partial update) and PUT
(full replace) semantics before returning.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14067 +/- ##
=======================================
Coverage 96.66% 96.66%
=======================================
Files 10 10
Lines 690 690
Branches 108 108
=======================================
Hits 667 667
Misses 8 8
Partials 15 15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
### What problem does this PR solve? Before change, update_document in api/apps/restful_apis/document_api.py is using "PUT". After change, it will use "PATCH" which is more suitable. ### Type of change - [x] Refactoring
What problem does this PR solve?
Before change, update_document in api/apps/restful_apis/document_api.py is using "PUT".
After change, it will use "PATCH" which is more suitable.
Type of change