Repository navigation
Refactor system/version API to RESTful style - #13956
Conversation
Signed-off-by: Jin Hai <[email protected]>
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment Tip CodeRabbit can suggest fixes for GitHub Check annotations.Configure the |
There was a problem hiding this comment.
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 | 🟠 MajorAlign the Swagger annotations with the final route contract.
These annotations currently describe
POST /api/v1/searcheswith a required body, whileinternal/router/router.go, Lines 204-206 registerGET /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
📒 Files selected for processing (5)
internal/handler/search.gointernal/router/router.gointernal/server/config.gointernal/service/search.goweb/src/utils/api.ts
| searches := v1.Group("/searches") | ||
| { | ||
| searches.GET("", r.searchHandler.ListSearches) |
There was a problem hiding this comment.
🧩 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
GETrequest, 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
TypeErrorif you try to send a non-null body withGET(orHEAD). So in-browser JS cannot reliably sendGETbodies. [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 aGETbody 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:
requestBodyis only supported where HTTP has defined request-body semantics; forGET(andHEAD/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 aGETrequest body. [5]
- OpenAPI 3.0.x:
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.
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
Request timed out after 900000ms (requestId=e69dff31-4602-4d9c-be5e-7d64c853f8ef) |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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]>
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/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
📒 Files selected for processing (4)
api/apps/restful_apis/system_api.pyapi/apps/system_app.pyinternal/handler/system.gointernal/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
| 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 |
There was a problem hiding this comment.
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.
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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]>
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
Request timed out after 900000ms (requestId=fd326ca1-0598-448f-b200-0a5671d0747d) |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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]>
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
|
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. |
|
No files have been changed in this PR. Unable to generate unit tests. |
### 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]>
What problem does this PR solve?
Refactor version API to RESTful style. Python and go server API also updated.
Type of change
Summary by CodeRabbit
Release Notes
Refactor
/api/v1/namespace for improved consistency and organization.New Features