Skip to content

Refactor: Change update doc from PUT to patch - #14067

Merged
yuzhichang merged 9 commits into
infiniflow:mainfrom
xugangqiang:change-update-doc-to-patch
Apr 14, 2026
Merged

yuzhichang merged 9 commits into
infiniflow:mainfrom
xugangqiang:change-update-doc-to-patch

Conversation

@xugangqiang

@xugangqiang xugangqiang commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Refactoring

@coderabbitai

coderabbitai Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

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: 6c0f4822-cbcf-4670-bfa1-e56b70ab73f4

📥 Commits

Reviewing files that changed from the base of the PR and between 547be28 and 65c58a7.

📒 Files selected for processing (3)
  • web/src/pages/agents/agent-templates.tsx
  • web/src/services/knowledge-service.ts
  • web/src/services/plugin-service.ts
✅ Files skipped from review due to trivial changes (2)
  • web/src/services/plugin-service.ts
  • web/src/pages/agents/agent-templates.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/services/knowledge-service.ts

📝 Walkthrough

Walkthrough

Standardizes 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

Cohort / File(s) Summary
Server API
api/apps/restful_apis/document_api.py
Route for /datasets/<dataset_id>/documents/<document_id> changed to register methods=["PATCH"] instead of ["PUT"].
Python SDK & Admin Client
sdk/python/ragflow_sdk/modules/document.py, admin/client/ragflow_client.py
Document update calls switched from PUT/.put() to PATCH/.patch() when sending update payloads; response parsing and error handling unchanged.
Test Helpers
test/testcases/test_http_api/common.py
Test helper update_document now issues requests.patch(...) instead of requests.put(...); payload/headers/auth unchanged.
Web frontend service
web/src/services/knowledge-service.ts
Removed documentRename map entry and changed exported renameDocument(...) to call API via request.patch(...) instead of put(...).
UI minor formatting
web/src/pages/agents/agent-templates.tsx, web/src/services/plugin-service.ts
Formatting and minor refactor of arrow-function/destructuring syntax; no behavioral changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

☯️ refactor, size:L, 🐖api

Suggested reviewers

  • JinHai-CN
  • yuzhichang

Poem

🐰 A tiny hop from PUT to PATCH,

I tweak the verbs and close the latch.
Clients, server, tests in sync,
A neat small change — quick as a wink! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change—converting HTTP method from PUT to PATCH for document updates across the codebase.
Description check ✅ Passed The description covers the main problem (switching from PUT to PATCH) and correctly selects the refactoring type, though it lacks detail on scope and rationale.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@xugangqiang
xugangqiang force-pushed the change-update-doc-to-patch branch from f95599b to fcb8752 Compare April 13, 2026 05:04
@xugangqiang xugangqiang added the ci Continue Integration label Apr 13, 2026
@xugangqiang
xugangqiang marked this pull request as ready for review April 13, 2026 05:18
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 13, 2026
@xugangqiang
xugangqiang force-pushed the change-update-doc-to-patch branch from fcb8752 to 547be28 Compare April 13, 2026 05:20

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

📥 Commits

Reviewing files that changed from the base of the PR and between 51ce6aa and 547be28.

📒 Files selected for processing (5)
  • admin/client/ragflow_client.py
  • api/apps/restful_apis/document_api.py
  • sdk/python/ragflow_sdk/modules/document.py
  • test/testcases/test_http_api/common.py
  • web/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

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.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
@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

codecov Bot commented Apr 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.66%. Comparing base (c22811f) to head (c5faa99).
⚠️ Report is 7 commits behind head on main.

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.
📢 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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 14, 2026
@xugangqiang xugangqiang self-assigned this Apr 14, 2026
@yuzhichang
yuzhichang merged commit 576431d into infiniflow:main Apr 14, 2026
1 check passed
@xugangqiang
xugangqiang deleted the change-update-doc-to-patch branch April 21, 2026 12:08
@coderabbitai coderabbitai Bot mentioned this pull request Apr 23, 2026
1 task done
JasleenKaurSethi pushed a commit to stackhpc/ragflow that referenced this pull request Apr 28, 2026
### 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants