From c242669a9d9458ef3e041f7d33b916310041f788 Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Tue, 14 Jul 2026 21:58:33 +0800 Subject: [PATCH] Go: fix bugs (#16911) ### Summary 1. Fix 'list users' in admin CLI 2. Change 3 slow test cases priority. Signed-off-by: Jin Hai --- internal/admin/handler.go | 4 +--- internal/admin/service.go | 7 +++++++ internal/cli/admin_command.go | 2 +- .../restful_api/test_dify_retrieval_routes_unit.py | 2 +- test/testcases/restful_api/test_openai_compatible.py | 2 +- .../test_dify_retrieval_routes_unit.py | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/admin/handler.go b/internal/admin/handler.go index 7209001605..0b53f16dc7 100644 --- a/internal/admin/handler.go +++ b/internal/admin/handler.go @@ -217,6 +217,7 @@ func (h *Handler) ListUsers(c *gin.Context) { } common.SuccessWithData(c, users, "List users") + return case common.EnterpriseEdition: users, err = h.service.ListUsersEE(pageInt, pageSizeInt, name, status, role, sort, orderBy, plan, topInt, daysInt, quotaInt) if err != nil { @@ -227,9 +228,6 @@ func (h *Handler) ListUsers(c *gin.Context) { common.ErrorWithCode(c, common.CodeBadRequest, "Invalid RAGFlow type") return } - - common.SuccessWithData(c, users, "List users") - return } // CreateUserHTTPRequest create user request diff --git a/internal/admin/service.go b/internal/admin/service.go index 6ee30fc6eb..61b32d72b5 100644 --- a/internal/admin/service.go +++ b/internal/admin/service.go @@ -1353,6 +1353,13 @@ func (s *Service) checkTaskExecutorAlive(name string) (map[string]interface{}, e func (s *Service) checkNatsAlive(name string, ip string, port int) (map[string]interface{}, error) { msgQueueEngine := engine.GetMessageQueueEngine() + if msgQueueEngine == nil { + return map[string]interface{}{ + "service_name": name, + "status": "Message queue engine not initialized", + }, nil + } + status := msgQueueEngine.CheckStatus() return map[string]interface{}{ diff --git a/internal/cli/admin_command.go b/internal/cli/admin_command.go index c31a8de8cd..2178cf97bc 100644 --- a/internal/cli/admin_command.go +++ b/internal/cli/admin_command.go @@ -1762,7 +1762,7 @@ func (c *CLI) AdminListUsersCommand(cmd *Command) (ResponseIf, error) { var result CommonResponse if err = json.Unmarshal(resp.Body, &result); err != nil { - return nil, fmt.Errorf("list users failed: invalid JSON (%w)", err) + return nil, fmt.Errorf("list users failed: invalid JSON (%w), body: %s", err, string(resp.Body)) } if result.Code != 0 { diff --git a/test/testcases/restful_api/test_dify_retrieval_routes_unit.py b/test/testcases/restful_api/test_dify_retrieval_routes_unit.py index be606d95ac..f1485e43d8 100644 --- a/test/testcases/restful_api/test_dify_retrieval_routes_unit.py +++ b/test/testcases/restful_api/test_dify_retrieval_routes_unit.py @@ -319,7 +319,7 @@ def test_retrieval_kb_not_found(monkeypatch): assert "Knowledgebase not found" in res["message"], res -@pytest.mark.p2 +@pytest.mark.p3 def test_retrieval_not_found_exception_mapping(monkeypatch): module = _load_dify_retrieval_module(monkeypatch) _set_request_json(monkeypatch, module, {"knowledge_id": "kb-1", "query": "hello"}) diff --git a/test/testcases/restful_api/test_openai_compatible.py b/test/testcases/restful_api/test_openai_compatible.py index efbbc7656c..0f1ba0497a 100644 --- a/test/testcases/restful_api/test_openai_compatible.py +++ b/test/testcases/restful_api/test_openai_compatible.py @@ -219,7 +219,7 @@ def test_openai_compatible_stream_shape_and_done_semantics(rest_client, create_c assert any(evt.get("choices", [{}])[0].get("finish_reason") == "stop" for evt in json_events), json_events -@pytest.mark.p2 +@pytest.mark.p3 def test_openai_compatible_reference_metadata_fields_filter_accepts_array(rest_client, create_chat): chat_id = create_chat("restful_openai_reference_fields_array_chat") res = rest_client.post( diff --git a/test/testcases/test_http_api/test_dataset_management/test_dify_retrieval_routes_unit.py b/test/testcases/test_http_api/test_dataset_management/test_dify_retrieval_routes_unit.py index 54bcfd7208..96e0170a8b 100644 --- a/test/testcases/test_http_api/test_dataset_management/test_dify_retrieval_routes_unit.py +++ b/test/testcases/test_http_api/test_dataset_management/test_dify_retrieval_routes_unit.py @@ -327,7 +327,7 @@ def test_retrieval_kb_not_found(monkeypatch): assert "Knowledgebase not found" in res["message"], res -@pytest.mark.p2 +@pytest.mark.p3 def test_retrieval_not_found_exception_mapping(monkeypatch): module = _load_dify_retrieval_module(monkeypatch) _set_request_json(monkeypatch, module, {"knowledge_id": "kb-1", "query": "hello"})