Skip to content

Refactor system/version API to RESTful style - #13956

Merged
JinHai-CN merged 6 commits into
infiniflow:mainfrom
JinHai-CN:fix372
Apr 7, 2026
Merged

JinHai-CN merged 6 commits into
infiniflow:mainfrom
JinHai-CN:fix372

Conversation

@JinHai-CN

@JinHai-CN JinHai-CN commented Apr 7, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

Refactor version API to RESTful style. Python and go server API also updated.

Type of change

  • Refactoring

Summary by CodeRabbit

Release Notes

  • Refactor

    • Migrated core API endpoints to the /api/v1/ namespace for improved consistency and organization.
    • Standardized system version, search, and chat list endpoints under the new API versioning structure.
  • New Features

    • Added MinIO region configuration support, allowing specification of storage engine regional settings via environment variables or configuration files.

@JinHai-CN JinHai-CN self-assigned this Apr 7, 2026
@JinHai-CN JinHai-CN added the ci Continue Integration label Apr 7, 2026
@coderabbitai

coderabbitai Bot commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ace0ea2-b167-4411-b239-034324001847

📥 Commits

Reviewing files that changed from the base of the PR and between 68f665b and a80f280.

📒 Files selected for processing (5)
  • internal/handler/search.go
  • internal/router/router.go
  • internal/server/config.go
  • internal/service/search.go
  • web/src/utils/api.ts
 __________________________________________________
< Your stack overflowed; I brought a bigger stack. >
 --------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

@JinHai-CN
JinHai-CN marked this pull request as ready for review April 7, 2026 07:29
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 7, 2026
@infiniflow infiniflow deleted a comment from coderabbitai Bot Apr 7, 2026

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/handler/search.go (1)

43-56: ⚠️ Potential issue | 🟠 Major

Align the Swagger annotations with the final route contract.

These annotations currently describe POST /api/v1/searches with a required body, while internal/router/router.go, Lines 204-206 register GET /api/v1/searches. Until the verb and parameter model match, generated docs and clients will be wrong for this endpoint.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/handler/search.go` around lines 43 - 56, The swagger comments for
the ListSearches handler (function ListSearches) are inconsistent with the
actual route registration (GET /api/v1/searches): change the annotations to
reflect a GET endpoint, remove the required request body param, and expose
filtering fields (keywords, page, page_size, orderby, desc and owner_ids) as
query parameters (or a single query param for owner_ids as CSV if applicable);
update the `@Param` entries accordingly and change the `@Router` line to use [get]
so generated docs/clients match the real route.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/router/router.go`:
- Around line 204-206: The ListSearches handler currently expects owner_ids from
the JSON body but the route is exposed as a GET (searches.GET("",
r.searchHandler.ListSearches)), which is unsafe; either change the router to use
POST for /api/v1/searches and update ListSearches signature to parse JSON body,
or keep GET and modify ListSearches to read owner_ids from query parameters
(e.g., owner_ids as repeated or comma-separated query value) and validate/parse
them there; update any OpenAPI/spec and client calls accordingly so request
method and payload location are consistent.

In `@internal/server/config.go`:
- Around line 469-472: The code dereferences globalConfig.StorageEngine.Minio
when setting Region which can panic if Minio is nil; guard and initialize before
assignment by checking if globalConfig.StorageEngine.Minio == nil and creating a
new Minio struct (or skipping the assignment) prior to setting
globalConfig.StorageEngine.Minio.Region; update the block that reads
MINIO_REGION to safely handle a nil Minio pointer.
- Around line 182-183: The Region value parsed into the config (Region field on
the config struct) is never passed into the MinIO client; update the
minio.New(...) call that constructs minio.Options (in your MinIO init code) to
include Region: m.config.Region so the client uses the configured region (i.e.,
add the Region property to the minio.Options passed to minio.New), ensuring you
reference the config via m.config.Region in the initialization code where
minio.New and minio.Options are used.

---

Outside diff comments:
In `@internal/handler/search.go`:
- Around line 43-56: The swagger comments for the ListSearches handler (function
ListSearches) are inconsistent with the actual route registration (GET
/api/v1/searches): change the annotations to reflect a GET endpoint, remove the
required request body param, and expose filtering fields (keywords, page,
page_size, orderby, desc and owner_ids) as query parameters (or a single query
param for owner_ids as CSV if applicable); update the `@Param` entries accordingly
and change the `@Router` line to use [get] so generated docs/clients match the
real route.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9ace0ea2-b167-4411-b239-034324001847

📥 Commits

Reviewing files that changed from the base of the PR and between 68f665b and a80f280.

📒 Files selected for processing (5)
  • internal/handler/search.go
  • internal/router/router.go
  • internal/server/config.go
  • internal/service/search.go
  • web/src/utils/api.ts

Comment thread internal/router/router.go
Comment on lines +204 to +206
searches := v1.Group("/searches")
{
searches.GET("", r.searchHandler.ListSearches)

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

🧩 Analysis chain

🌐 Web query:

Are request bodies on HTTP GET endpoints reliably supported by browsers, proxies, caches, and OpenAPI/Swagger tooling?

💡 Result:

No—a request body on an HTTP GET is not reliably supported across the ecosystem, and you should generally avoid designing APIs that require it.

  • HTTP semantics / intermediaries: HTTP does not define generally-applicable semantics for content in a GET request, and it explicitly warns that some implementations might reject such requests (e.g., due to request-smuggling concerns). It also warns servers shouldn’t rely on “private agreements” because intermediaries may exist in the path. [1]
  • Browsers (Fetch): The Fetch standard used by modern browsers throws a TypeError if you try to send a non-null body with GET (or HEAD). So in-browser JS cannot reliably send GET bodies. [2]
  • Caches / proxies: HTTP caching keys are based at minimum on method + target URI, and many caches effectively key only on the URI for GET. That means a GET body generally won’t be part of cache selection, creating a real risk of incorrect cache hits/misses or ignored bodies. [3]
  • OpenAPI / Swagger tooling:
    • OpenAPI 3.0.x: requestBody is only supported where HTTP has defined request-body semantics; for GET (and HEAD/DELETE) it “SHALL be ignored by consumers.” [4]
    • Swagger / OpenAPI 2.0: Documentation for request bodies describes them for POST/PUT/PATCH, not GET, and many Swagger UI / codegen tools therefore won’t model or render a GET request body. [5]

Practical guidance: If you need a payload, use POST (commonly for “search” endpoints), or encode inputs into the query string (within length/security constraints), rather than relying on a GET body.

Sources: RFC 9110 (HTTP Semantics) [1], WHATWG Fetch [2], RFC 9111 (HTTP Caching) [3], OpenAPI 3.0.4 spec [4], Swagger (OpenAPI 2.0) docs [5].


🏁 Script executed:

cat -n internal/handler/search.go | sed -n '85,105p'

Repository: infiniflow/ragflow

Length of output: 787


🏁 Script executed:

cat -n internal/router/router.go | sed -n '200,210p'

Repository: infiniflow/ragflow

Length of output: 326


Move owner_ids to query parameters or change endpoint to POST.

ListSearches handler reads owner_ids from JSON body (internal/handler/search.go, line 92), but the endpoint is exposed as GET /api/v1/searches (internal/router/router.go, line 206). HTTP GET with a request body is not reliably supported: browsers throw errors, caches ignore the body, proxies may reject it, and OpenAPI/Swagger tools ignore it. This creates a real risk of silent failures when clients or intermediaries encounter the endpoint.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/router/router.go` around lines 204 - 206, The ListSearches handler
currently expects owner_ids from the JSON body but the route is exposed as a GET
(searches.GET("", r.searchHandler.ListSearches)), which is unsafe; either change
the router to use POST for /api/v1/searches and update ListSearches signature to
parse JSON body, or keep GET and modify ListSearches to read owner_ids from
query parameters (e.g., owner_ids as repeated or comma-separated query value)
and validate/parse them there; update any OpenAPI/spec and client calls
accordingly so request method and payload location are consistent.

Comment thread internal/server/config.go Resolved
Comment thread internal/server/config.go Resolved
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@codecov

codecov Bot commented Apr 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.52%. Comparing base (38acf34) to head (a2753dd).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13956   +/-   ##
=======================================
  Coverage   96.52%   96.52%           
=======================================
  Files          10       10           
  Lines         690      690           
  Branches      108      108           
=======================================
  Hits          666      666           
  Misses          8        8           
  Partials       16       16           

☔ 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.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Request timed out after 900000ms (requestId=e69dff31-4602-4d9c-be5e-7d64c853f8ef)

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

Signed-off-by: Jin Hai <[email protected]>
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Apr 7, 2026

@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/system_api.py`:
- Around line 24-42: Add logging to the new authenticated endpoint flow in the
version() function: obtain or reuse the module logger (e.g.,
logging.getLogger(__name__) or the existing app/process logger), emit an INFO
log when the endpoint is entered (include caller/context like user/api key if
available), emit DEBUG or INFO with the result from get_ragflow_version() before
returning via get_json_result(), and emit ERROR if any exception occurs while
fetching the version; reference the version(), get_ragflow_version(), and
get_json_result() symbols so the logs are placed around the call and the return
path.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 64f39b30-56b5-4e43-88ba-fac1f1eace07

📥 Commits

Reviewing files that changed from the base of the PR and between a80f280 and fca53d9.

📒 Files selected for processing (4)
  • api/apps/restful_apis/system_api.py
  • api/apps/system_app.py
  • internal/handler/system.go
  • internal/router/router.go
💤 Files with no reviewable changes (1)
  • api/apps/system_app.py
✅ Files skipped from review due to trivial changes (1)
  • internal/handler/system.go

Comment on lines +24 to +42
def version():
"""
Get the current version of the application.
---
tags:
- System
security:
- ApiKeyAuth: []
responses:
200:
description: Version retrieved successfully.
schema:
type: object
properties:
version:
type: string
description: Version number.
"""
return get_json_result(data=get_ragflow_version()) No newline at end of file

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 | 🟡 Minor

Add logging for this new endpoint flow.

version() introduces a new authenticated flow but has no log entry, which reduces observability.

💡 Proposed fix
+import logging
+
 from api.apps import login_required
 from api.utils.api_utils import get_json_result
 from common.versions import get_ragflow_version
 
+logger = logging.getLogger(__name__)
+
 `@manager.route`("/system/version", methods=["GET"])
 `@login_required`
 def version():
@@
-    return get_json_result(data=get_ragflow_version())
+    version_value = get_ragflow_version()
+    logger.info("System version requested")
+    return get_json_result(data=version_value)

As per coding guidelines **/*.py: Add logging for new flows.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/apps/restful_apis/system_api.py` around lines 24 - 42, Add logging to the
new authenticated endpoint flow in the version() function: obtain or reuse the
module logger (e.g., logging.getLogger(__name__) or the existing app/process
logger), emit an INFO log when the endpoint is entered (include caller/context
like user/api key if available), emit DEBUG or INFO with the result from
get_ragflow_version() before returning via get_json_result(), and emit ERROR if
any exception occurs while fetching the version; reference the version(),
get_ragflow_version(), and get_json_result() symbols so the logs are placed
around the call and the return path.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

Signed-off-by: Jin Hai <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Request timed out after 900000ms (requestId=fd326ca1-0598-448f-b200-0a5671d0747d)

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

Signed-off-by: Jin Hai <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@JinHai-CN
JinHai-CN merged commit 9310218 into infiniflow:main Apr 7, 2026
1 check passed
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

No files have been changed in this PR. Unable to generate unit tests.

@coderabbitai coderabbitai Bot mentioned this pull request Apr 22, 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?

Refactor version API to RESTful style. Python and go server API also
updated.
### Type of change

- [x] Refactoring



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

* **Refactor**
* Migrated core API endpoints to the `/api/v1/` namespace for improved
consistency and organization.
* Standardized system version, search, and chat list endpoints under the
new API versioning structure.

* **New Features**
* Added MinIO region configuration support, allowing specification of
storage engine regional settings via environment variables or
configuration files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Jin Hai <[email protected]>
@coderabbitai coderabbitai Bot mentioned this pull request May 8, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant