From 415169d49772baa51a308ca2ba7287f71aba0601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=9C=A3=E7=A5=BA?= Date: Tue, 12 May 2026 09:37:07 +0800 Subject: [PATCH] fix(dify): add GET method support to /dify/retrieval for health check (#13837) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Add GET method handler to `/api/v1/dify/retrieval` endpoint for Dify external knowledge base connectivity verification - GET requests return a simple success response; POST requests retain existing retrieval logic unchanged ## Problem When Dify integrates with RAGFlow as an external knowledge base, it sends periodic GET requests to the retrieval endpoint for health/connectivity checks. The endpoint only accepted POST, causing werkzeug to return `405 Method Not Allowed`. After several successful POST retrievals, the failing GET health checks trigger Dify's circuit breaker, causing all subsequent requests to fail. Traceback from the issue: ``` werkzeug.exceptions.MethodNotAllowed: 405 Method Not Allowed: The method is not allowed for the requested URL. ``` ## Changes - `api/apps/sdk/dify_retrieval.py`: Added a separate GET route handler (`retrieval_health_check`) that returns `get_json_result(data=True)` ## Test plan - [ ] Verify `GET /api/v1/dify/retrieval` returns `{"code": 0, "message": "success", "data": true}` - [ ] Verify `POST /api/v1/dify/retrieval` with valid API key and body still works as before - [ ] Verify Dify external knowledge base integration no longer returns 405 errors Closes #13788 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Asksksn Co-authored-by: Claude Opus 4.6 Co-authored-by: Kevin Hu --- api/apps/sdk/dify_retrieval.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/apps/sdk/dify_retrieval.py b/api/apps/sdk/dify_retrieval.py index ab0e126269..05885c380b 100644 --- a/api/apps/sdk/dify_retrieval.py +++ b/api/apps/sdk/dify_retrieval.py @@ -29,7 +29,7 @@ from api.db.services.knowledgebase_service import KnowledgebaseService from api.db.services.llm_service import LLMBundle from api.db.joint_services.tenant_model_service import get_model_config_by_id, get_model_config_by_type_and_name, get_tenant_default_model_by_type from common.metadata_utils import meta_filter, convert_conditions -from api.utils.api_utils import apikey_required, build_error_result, get_request_json +from api.utils.api_utils import apikey_required, build_error_result, get_request_json, get_json_result from rag.app.tag import label_question from common.constants import RetCode, LLMType from common import settings @@ -311,3 +311,10 @@ async def retrieval(tenant_id): ) logging.exception(e) return build_error_result(message=str(e), code=RetCode.SERVER_ERROR) + + +@manager.route('/dify/retrieval', methods=['GET']) # noqa: F821 +async def retrieval_health_check(): + """Health check endpoint for Dify external knowledge base connectivity verification.""" + return get_json_result(data=True) +