Skip to content

Go CLI: admin list providers - #16243

Merged
JinHai-CN merged 6 commits into
infiniflow:mainfrom
JinHai-CN:fix478
Jun 23, 2026
Merged

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

Conversation

@JinHai-CN

@JinHai-CN JinHai-CN commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

RAGFlow(admin)> list providers;
+----------------------+-------------------------------------------------------------+
| command              | error                                                       |
+----------------------+-------------------------------------------------------------+
| list_model_providers | 'list model providers' is implemented in enterprise edition |
+----------------------+-------------------------------------------------------------+

RAGFlow(admin)> add provider 'zhipu-ai';
+-------------+-----------------------------------------------------------+
| field       | value                                                     |
+-------------+-----------------------------------------------------------+
| command     | add_model_provider                                        |
| error       | 'add model provider' is implemented in enterprise edition |
| provider_id | admin                                                     |
| user_id     | zhipu-ai                                                  |
+-------------+-----------------------------------------------------------+

RAGFlow(admin)> delete provider 'zhipu-ai';
+-------------+--------------------------------------------------------------+
| field       | value                                                        |
+-------------+--------------------------------------------------------------+
| command     | delete_model_provider                                        |
| error       | 'delete model provider' is implemented in enterprise edition |
| provider_id | admin                                                        |
| user_id     | zhipu-ai                                                     |
+-------------+--------------------------------------------------------------+

RAGFlow(admin)> add provider 'zhipu-ai' instance 'instance1';
+---------------+-----------------------------------------------------------+
| field         | value                                                     |
+---------------+-----------------------------------------------------------+
| command       | add_model_instance                                        |
| error         | 'add model instance' is implemented in enterprise edition |
| instance_name | instance1                                                 |
| provider_id   | zhipu-ai                                                  |
| user_id       | admin                                                     |
+---------------+-----------------------------------------------------------+

RAGFlow(admin)> delete provider 'zhipu-ai' instance 'test'
+-------------+--------------------------------------------------------------+
| field       | value                                                        |
+-------------+--------------------------------------------------------------+
| instances   | [test]                                                       |
| provider_id | zhipu-ai                                                     |
| user_id     | admin                                                        |
| command     | delete_model_provider                                        |
| error       | 'delete model instance' is implemented in enterprise edition |
+-------------+--------------------------------------------------------------+

RAGFlow(admin)> add provider 'zhipu-ai' instance 'instance1' model 'xxx';
+---------------+--------------------------------------------------+
| field         | value                                            |
+---------------+--------------------------------------------------+
| command       | add_model                                        |
| error         | 'add model' is implemented in enterprise edition |
| instance_name | instance1                                        |
| model_names   | [xxx]                                            |
| provider_id   | zhipu-ai                                         |
| user_id       | admin                                            |
+---------------+--------------------------------------------------+

RAGFlow(admin)> delete provider 'zhipu-ai' instance 'test' model 'xxx';
+---------------+------------------------------------------------------+
| field         | value                                                |
+---------------+------------------------------------------------------+
| command       | delete_model_provider                                |
| error         | 'delete models' is implemented in enterprise edition |
| instance_name | test                                                 |
| models        | [xxx]                                                |
| provider_id   | zhipu-ai                                             |
| user_id       | admin                                                |
+---------------+------------------------------------------------------+

Type of change

  • New Feature (non-breaking change which adds functionality)

@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds admin API endpoints and CLI commands for managing model providers, model instances, and models in a three-level hierarchy. Enterprise service stubs are added for all operations. The admin HTTP router is rewired to renamed handler functions. CLI parser grammar is extended for LIST/ADD/DELETE PROVIDER ... INSTANCE ... MODEL syntax. A DeleteModelProvider argument order bug is also fixed.

Changes

Admin model provider/instance/model management

Layer / File(s) Summary
Enterprise service stubs, HTTP handlers, and router wiring
internal/admin/enterprise_service.go, internal/admin/enterprise_handler.go, internal/admin/router.go
Adds enterprise-edition stubs for all provider/instance/model operations returning an "implemented in enterprise edition" marker. HTTP handlers bind JSON params, read path params (provider_name, instance_name), delegate to the service, and return success or error responses. The /providers router group is rewired to the new ListModelProviders, AddModelProvider, DeleteModelProvider, AddModelInstance, DeleteModelInstance, AddModels, and DeleteModels handler names.
CLI parser grammar for LIST/ADD/DELETE provider hierarchy
internal/cli/admin_parser.go, internal/cli/parser.go
Renames parseAdminListCommand to parseAdminListCommands and adds a TokenProviders branch routing to parseAdminListProviders. Adds parseAdminAddModelProvider, parseAdminAddModelInstance, and parseAdminAddModel for hierarchical ADD grammar. Adds parseAdminDeleteCommands, parseAdminDeleteProvider, parseAdminDeleteModelInstance, and parseAdminDeleteModel for hierarchical DELETE grammar. Removes defunct parseAdminDropModelProvider. Top-level admin dispatch is updated to call the renamed plural handlers.
CLI command implementations and dispatch
internal/cli/admin_command.go, internal/cli/cli_http.go, internal/cli/response.go
Adds AdminListProvidersCommand, AdminAddProviderCommand, AdminAddModelInstanceCommand, AdminAddModelsCommand, AdminDeleteProvidersCommand, AdminDeleteInstancesCommand, and AdminDeleteModelsCommand, each enforcing admin mode and calling the corresponding HTTP endpoint. Adds UserIndexResponse wrapping CommonDataResponse. ExecuteAdminCommand switch is extended to route all new command names.
Argument order bugfix and api_key removal
internal/handler/providers.go, internal/cli/user_command.go, internal/cli/user_parser.go
Fixes DeleteModelProvider call to pass (userID, providerName) instead of (providerName, userID). Removes the documented api_key argument from the ADD PROVIDER CLI comment and drops the optional api_key parsing logic from parseAddProvider.

Sequence Diagram(s)

sequenceDiagram
  participant AdminCLI
  participant ExecuteAdminCommand
  participant AdminCommand
  participant AdminHTTPAPI
  participant enterprise_handler
  participant enterprise_service

  AdminCLI->>ExecuteAdminCommand: admin_add_provider / admin_add_model_instance / admin_add_models
  ExecuteAdminCommand->>AdminCommand: AdminAddProviderCommand / AdminAddModelInstanceCommand / AdminAddModelsCommand
  AdminCommand->>AdminHTTPAPI: POST /admin/providers[/{provider}/instances[/{instance}/models]]
  AdminHTTPAPI->>enterprise_handler: AddModelProvider / AddModelInstance / AddModels
  enterprise_handler->>enterprise_service: AddModelProvider / AddModelInstance / AddModels(userID, ...)
  enterprise_service-->>enterprise_handler: {command, error: "enterprise edition"}, nil
  enterprise_handler-->>AdminHTTPAPI: success(data)
  AdminHTTPAPI-->>AdminCommand: HTTP 200 + CommonDataResponse
  AdminCommand-->>ExecuteAdminCommand: &result
  ExecuteAdminCommand-->>AdminCLI: ResponseIf
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • infiniflow/ragflow#16240: Modifies the same internal/admin/enterprise_handler.go provider-listing handler layer, with overlapping rename/replacement of ListProviders-style endpoint behavior.

Suggested labels

💞 feature, size:XXL

🐇 Hoppity hop, new routes appear,
Providers, instances, models are here!
The parser now knows ADD and DELETE,
With hierarchy trees, oh what a feat.
Enterprise stubs stand guard with care —
A rabbit wired it all with flair! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'Go CLI: admin list providers' is overly narrow and does not reflect the main scope of changes, which encompass much broader admin provider and model management functionality including add, delete, and hierarchical operations. Revise the title to better reflect the complete feature scope, such as 'Admin CLI: implement model provider and instance management commands' or 'Add admin CLI commands for managing model providers and instances'.
Description check ⚠️ Warning The PR description includes practical command examples and the required 'Type of change' section, but omits the 'What problem does this PR solve?' section which is required by the template. Add a 'What problem does this PR solve?' section that explains the motivation and context for implementing these admin CLI commands for provider management.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

❤️ Share

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

@JinHai-CN
JinHai-CN marked this pull request as ready for review June 22, 2026 12:58
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 22, 2026
@JinHai-CN JinHai-CN added ci Continue Integration and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jun 22, 2026
@dosubot dosubot Bot added the 💞 feature Feature request, pull request that fullfill a new feature. label Jun 22, 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: 5

🧹 Nitpick comments (2)
internal/admin/enterprise_handler.go (1)

294-311: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Dead code: keywords variable is computed but never used.

The handler reads and processes the available query parameter into the keywords variable (lines 296-302) but never passes it to h.service.ListModelProviders() or uses it in any way.

♻️ Remove unused code
 func (h *Handler) ListModelProviders(c *gin.Context) {
-
-	keywords := ""
-	if queryKeywords := c.Query("available"); queryKeywords != "" {
-		keywords = queryKeywords
-	}
-
-	// convert keywords to small case
-	keywords = strings.ToLower(keywords)
-
 	result, err := h.service.ListModelProviders()
 	if err != nil {
 		errorResponse(c, err.Error(), 500)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/admin/enterprise_handler.go` around lines 294 - 311, The
ListModelProviders handler is reading and processing the "available" query
parameter into the keywords variable and converting it to lowercase, but this
variable is never passed to the h.service.ListModelProviders() call or used
anywhere else in the function. Remove the dead code by deleting the variable
declaration and assignment lines that extract the query parameter (the code that
retrieves c.Query("available") and calls strings.ToLower()), as this logic
serves no purpose if the keywords value is not being utilized by the service
method.
internal/cli/admin_command.go (1)

3415-3418: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Error message refers to singular instance_name but param key is instance_names.

The error message says "instance_name not provided" but the code checks for instance_names (plural). This could confuse users debugging issues.

Proposed fix
 	instanceNames, ok := cmd.Params["instance_names"].([]string)
 	if !ok {
-		return nil, fmt.Errorf("instance_name not provided")
+		return nil, fmt.Errorf("instance_names not provided")
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/admin_command.go` around lines 3415 - 3418, The error message in
the type assertion check for the instance_names parameter is inconsistent with
the actual parameter key being validated. Update the error message in the
fmt.Errorf call to match the parameter name being checked. Change the error
message from "instance_name not provided" to "instance_names not provided"
(using the plural form that matches the cmd.Params key "instance_names") so the
error message accurately reflects what parameter is expected.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/admin/enterprise_handler.go`:
- Around line 484-512: The success message in the DeleteModelInstance function
method is incorrect. At the end of the function where success(c, result, "Model
provider added successfully") is called, change the message string to accurately
reflect that model instances were deleted rather than a provider being added.
Update the message parameter to something like "Model instances deleted
successfully" to match the operation being performed.
- Around line 317-337: The AddModelProvider method call in the AddModelProvider
handler function is passing arguments in the wrong order. The service method
signature expects userID as the first parameter and providerName as the second
parameter, but the handler is currently calling it with req.ProviderName first
and userID second. Swap the argument order in the h.service.AddModelProvider
call to match the expected signature by passing userID first, followed by
req.ProviderName.

In `@internal/cli/admin_parser.go`:
- Around line 1811-1823: In the parseAdminDeleteCommands function, the error
message returned in the default case contains a copy-paste error. Change the
error message from "unknown ADD target" to "unknown DELETE target" to accurately
reflect that this is a DELETE command parser, not an ADD command parser.

In `@internal/cli/response.go`:
- Around line 91-97: The UserIndexResponse struct is missing three required
methods to fully implement the ResponseIf interface. In addition to the existing
TimeCost() method, you need to implement Type(), PrintOut(), and
SetOutputFormat() methods for UserIndexResponse. Reference the implementations
in other response types like ModelsResponse, CommonDataResponse, and
SimpleResponse in the same file to understand the expected signatures and
behavior patterns, then add these three missing methods to UserIndexResponse
following the same pattern.

In `@internal/handler/providers.go`:
- Line 147: The DeleteModelProvider method call in the handler is passing
arguments in the wrong order. The h.modelProviderService.DeleteModelProvider
call currently passes userID first and providerName second, but the service
method signature expects providerName as the first parameter and userID as the
second parameter. Swap the order of the arguments in the DeleteModelProvider
call to match the service method signature.

---

Nitpick comments:
In `@internal/admin/enterprise_handler.go`:
- Around line 294-311: The ListModelProviders handler is reading and processing
the "available" query parameter into the keywords variable and converting it to
lowercase, but this variable is never passed to the
h.service.ListModelProviders() call or used anywhere else in the function.
Remove the dead code by deleting the variable declaration and assignment lines
that extract the query parameter (the code that retrieves c.Query("available")
and calls strings.ToLower()), as this logic serves no purpose if the keywords
value is not being utilized by the service method.

In `@internal/cli/admin_command.go`:
- Around line 3415-3418: The error message in the type assertion check for the
instance_names parameter is inconsistent with the actual parameter key being
validated. Update the error message in the fmt.Errorf call to match the
parameter name being checked. Change the error message from "instance_name not
provided" to "instance_names not provided" (using the plural form that matches
the cmd.Params key "instance_names") so the error message accurately reflects
what parameter is expected.
🪄 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: 9a51f4bf-268d-4196-84f6-f9225fddd478

📥 Commits

Reviewing files that changed from the base of the PR and between 06ededb and 1ce32a4.

📒 Files selected for processing (11)
  • internal/admin/enterprise_handler.go
  • internal/admin/enterprise_service.go
  • internal/admin/router.go
  • internal/cli/admin_command.go
  • internal/cli/admin_parser.go
  • internal/cli/cli_http.go
  • internal/cli/parser.go
  • internal/cli/response.go
  • internal/cli/user_command.go
  • internal/cli/user_parser.go
  • internal/handler/providers.go
💤 Files with no reviewable changes (2)
  • internal/cli/user_command.go
  • internal/cli/user_parser.go

Comment on lines +317 to 337
func (h *Handler) AddModelProvider(c *gin.Context) {
var req AddProviderRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": providers,
"code": common.CodeBadRequest,
"message": err.Error(),
"data": false,
})
return
}

userID := c.GetString("user_id")

result, err := h.service.AddModelProvider(req.ProviderName, userID)
if err != nil {
errorResponse(c, err.Error(), 500)
return
}

success(c, result, "Model provider added successfully")
}

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 | 🔴 Critical | ⚡ Quick win

Critical: Arguments passed in wrong order to AddModelProvider.

Line 330 calls h.service.AddModelProvider(req.ProviderName, userID), but the service method signature at line 177 of internal/admin/enterprise_service.go is AddModelProvider(userID, providerName string). This causes the provider name to be stored as the user ID and vice versa.

🐛 Swap the argument order
-	result, err := h.service.AddModelProvider(req.ProviderName, userID)
+	result, err := h.service.AddModelProvider(userID, req.ProviderName)
 	if err != nil {
 		errorResponse(c, err.Error(), 500)
📝 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
func (h *Handler) AddModelProvider(c *gin.Context) {
var req AddProviderRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": providers,
"code": common.CodeBadRequest,
"message": err.Error(),
"data": false,
})
return
}
userID := c.GetString("user_id")
result, err := h.service.AddModelProvider(req.ProviderName, userID)
if err != nil {
errorResponse(c, err.Error(), 500)
return
}
success(c, result, "Model provider added successfully")
}
func (h *Handler) AddModelProvider(c *gin.Context) {
var req AddProviderRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeBadRequest,
"message": err.Error(),
"data": false,
})
return
}
userID := c.GetString("user_id")
result, err := h.service.AddModelProvider(userID, req.ProviderName)
if err != nil {
errorResponse(c, err.Error(), 500)
return
}
success(c, result, "Model provider added successfully")
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/admin/enterprise_handler.go` around lines 317 - 337, The
AddModelProvider method call in the AddModelProvider handler function is passing
arguments in the wrong order. The service method signature expects userID as the
first parameter and providerName as the second parameter, but the handler is
currently calling it with req.ProviderName first and userID second. Swap the
argument order in the h.service.AddModelProvider call to match the expected
signature by passing userID first, followed by req.ProviderName.

Comment on lines +484 to +512
func (h *Handler) DeleteModelInstance(c *gin.Context) {
providerName := c.Param("provider_name")
if providerName == "" {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "Provider name is required",
})
return
}

var req DropModelInstanceRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeBadRequest,
"message": err.Error(),
})
return
}

userID := c.GetString("user_id")

result, err := h.service.DeleteModelInstances(userID, providerName, req.InstanceNames)
if err != nil {
errorResponse(c, err.Error(), 500)
return
}

success(c, result, "Model provider added successfully")
}

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 | ⚡ Quick win

Incorrect success message for delete operation.

Line 511 returns "Model provider added successfully" for a delete operation. The message should indicate that model instances were deleted.

📝 Fix the success message
-	success(c, result, "Model provider added successfully")
+	success(c, result, "Model instances deleted successfully")
 }
📝 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
func (h *Handler) DeleteModelInstance(c *gin.Context) {
providerName := c.Param("provider_name")
if providerName == "" {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "Provider name is required",
})
return
}
var req DropModelInstanceRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeBadRequest,
"message": err.Error(),
})
return
}
userID := c.GetString("user_id")
result, err := h.service.DeleteModelInstances(userID, providerName, req.InstanceNames)
if err != nil {
errorResponse(c, err.Error(), 500)
return
}
success(c, result, "Model provider added successfully")
}
func (h *Handler) DeleteModelInstance(c *gin.Context) {
providerName := c.Param("provider_name")
if providerName == "" {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "Provider name is required",
})
return
}
var req DropModelInstanceRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeBadRequest,
"message": err.Error(),
})
return
}
userID := c.GetString("user_id")
result, err := h.service.DeleteModelInstances(userID, providerName, req.InstanceNames)
if err != nil {
errorResponse(c, err.Error(), 500)
return
}
success(c, result, "Model instances deleted successfully")
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/admin/enterprise_handler.go` around lines 484 - 512, The success
message in the DeleteModelInstance function method is incorrect. At the end of
the function where success(c, result, "Model provider added successfully") is
called, change the message string to accurately reflect that model instances
were deleted rather than a provider being added. Update the message parameter to
something like "Model instances deleted successfully" to match the operation
being performed.

Comment on lines +1811 to 1823
func (p *Parser) parseAdminDeleteCommands() (*Command, error) {
p.nextToken() // consume DELETE
switch p.curToken.Type {
case TokenAPI:
return p.parseDeleteAPIServer()
case TokenAdmin:
return p.parseDeleteAdminServer()
case TokenProvider:
return p.parseAdminDeleteProvider()
default:
return nil, fmt.Errorf("unknown ADD target: %s", p.curToken.Value)
}
}

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 | ⚡ Quick win

Copy-paste error in error message.

The error message says "unknown ADD target" but this is in parseAdminDeleteCommands. Should be "unknown DELETE target".

Proposed fix
 func (p *Parser) parseAdminDeleteCommands() (*Command, error) {
 	p.nextToken() // consume DELETE
 	switch p.curToken.Type {
 	case TokenAPI:
 		return p.parseDeleteAPIServer()
 	case TokenAdmin:
 		return p.parseDeleteAdminServer()
 	case TokenProvider:
 		return p.parseAdminDeleteProvider()
 	default:
-		return nil, fmt.Errorf("unknown ADD target: %s", p.curToken.Value)
+		return nil, fmt.Errorf("unknown DELETE target: %s", p.curToken.Value)
 	}
 }
📝 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
func (p *Parser) parseAdminDeleteCommands() (*Command, error) {
p.nextToken() // consume DELETE
switch p.curToken.Type {
case TokenAPI:
return p.parseDeleteAPIServer()
case TokenAdmin:
return p.parseDeleteAdminServer()
case TokenProvider:
return p.parseAdminDeleteProvider()
default:
return nil, fmt.Errorf("unknown ADD target: %s", p.curToken.Value)
}
}
func (p *Parser) parseAdminDeleteCommands() (*Command, error) {
p.nextToken() // consume DELETE
switch p.curToken.Type {
case TokenAPI:
return p.parseDeleteAPIServer()
case TokenAdmin:
return p.parseDeleteAdminServer()
case TokenProvider:
return p.parseAdminDeleteProvider()
default:
return nil, fmt.Errorf("unknown DELETE target: %s", p.curToken.Value)
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/admin_parser.go` around lines 1811 - 1823, In the
parseAdminDeleteCommands function, the error message returned in the default
case contains a copy-paste error. Change the error message from "unknown ADD
target" to "unknown DELETE target" to accurately reflect that this is a DELETE
command parser, not an ADD command parser.

Comment thread internal/cli/response.go
Comment on lines +91 to +97
type UserIndexResponse struct {
InternalData CommonDataResponse
}

func (r *UserIndexResponse) TimeCost() float64 {
return r.InternalData.Duration
}

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check usage of UserIndexResponse
rg -n 'UserIndexResponse' --type=go

Repository: infiniflow/ragflow

Length of output: 199


🏁 Script executed:

#!/bin/bash
# Find the ResponseIf interface definition
rg -n 'type ResponseIf' --type=go -A 10

# Also check what other response types exist in the same file
rg -n 'type.*Response struct' internal/cli/response.go

Repository: infiniflow/ragflow

Length of output: 1378


🏁 Script executed:

#!/bin/bash
# Check implementations of the interface in other response types
# Look at ModelsResponse, CommonDataResponse, and a few others to see if they implement all methods

echo "=== ModelsResponse implementation ==="
rg -n 'func \(r \*ModelsResponse\)' internal/cli/response.go

echo "=== CommonDataResponse implementation ==="
rg -n 'func \(r \*CommonDataResponse\)' internal/cli/response.go

echo "=== SimpleResponse implementation ==="
rg -n 'func \(r \*SimpleResponse\)' internal/cli/response.go

echo "=== Full UserIndexResponse definition ==="
sed -n '91,98p' internal/cli/response.go

Repository: infiniflow/ragflow

Length of output: 1001


UserIndexResponse does not fully implement ResponseIf interface.

The ResponseIf interface requires Type(), PrintOut(), TimeCost(), and SetOutputFormat() methods. UserIndexResponse only implements TimeCost(), missing the other three methods required by the interface. Other response types in this file (e.g., ModelsResponse, CommonDataResponse, SimpleResponse) properly implement all four methods. Either implement the missing methods or clarify if this type is intentionally not a ResponseIf.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/cli/response.go` around lines 91 - 97, The UserIndexResponse struct
is missing three required methods to fully implement the ResponseIf interface.
In addition to the existing TimeCost() method, you need to implement Type(),
PrintOut(), and SetOutputFormat() methods for UserIndexResponse. Reference the
implementations in other response types like ModelsResponse, CommonDataResponse,
and SimpleResponse in the same file to understand the expected signatures and
behavior patterns, then add these three missing methods to UserIndexResponse
following the same pattern.

userID := c.GetString("user_id")

errorCode, err := h.modelProviderService.DeleteModelProvider(providerName, userID)
errorCode, err := h.modelProviderService.DeleteModelProvider(userID, providerName)

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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify DeleteModelProvider signature and find all callers

# Find the service method definition
echo "=== DeleteModelProvider method definition ==="
ast-grep --pattern $'func ($$$) DeleteModelProvider($$$) ($$$) {
  $$$
}'

# Find all callers of DeleteModelProvider
echo -e "\n=== All calls to DeleteModelProvider ==="
rg -nP '\bDeleteModelProvider\s*\(' -A 2 -B 2 --type=go

Repository: infiniflow/ragflow

Length of output: 2405


Fix argument order in DeleteModelProvider call.

The handler is calling DeleteModelProvider(userID, providerName) but the service method signature at internal/service/model_service.go:190 expects DeleteModelProvider(providerName, userID string). Swap the argument order to match the signature. There are no other callers of this method that need the same fix.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/handler/providers.go` at line 147, The DeleteModelProvider method
call in the handler is passing arguments in the wrong order. The
h.modelProviderService.DeleteModelProvider call currently passes userID first
and providerName second, but the service method signature expects providerName
as the first parameter and userID as the second parameter. Swap the order of the
arguments in the DeleteModelProvider call to match the service method signature.

@JinHai-CN JinHai-CN added ci Continue Integration and removed ci Continue Integration labels Jun 23, 2026
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (06ededb) to head (1ce32a4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16243      +/-   ##
==========================================
- Coverage   94.56%   93.16%   -1.40%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      668      -10     
- Misses         25       29       +4     
- Partials       14       20       +6     

☔ View full report in Codecov by Harness.
📢 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.

@JinHai-CN
JinHai-CN merged commit b661e9c into infiniflow:main Jun 23, 2026
15 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant