Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: apply configured timeout to enterprise inner API requests (#39335)
Xiyuan Chen3f0f57c5941b
diff --git a/api/services/enterprise/base.py b/api/services/enterprise/base.pyindex 96c362b3dfc..5ddb51b0696 100644--- a/api/services/enterprise/base.py+++ b/api/services/enterprise/base.py@@ -5,6 +5,7 @@ from typing import Anyimport httpx+from configs import dify_configfrom core.helper.trace_id_helper import generate_traceparent_headerfrom services.errors.enterprise import (EnterpriseAPIBadRequestError,@@ -96,12 +97,14 @@ class BaseRequest:logger.debug("Failed to generate traceparent header", exc_info=True)with httpx.Client(mounts=mounts) as client:- # IMPORTANT:- # - In httpx, passing timeout=None disables timeouts (infinite) and overrides the library default.- # - To preserve httpx's default timeout behavior for existing call sites, only pass the kwarg when set.- request_kwargs: dict[str, Any] = {"json": json, "params": params, "headers": headers}- if timeout is not None:- request_kwargs["timeout"] = timeout+ # Callers that pass an explicit timeout keep it; everyone else gets the+ # configured budget rather than httpx's implicit 5s default.+ request_kwargs: dict[str, Any] = {+ "json": json,+ "params": params,+ "headers": headers,+ "timeout": timeout if timeout is not None else dify_config.ENTERPRISE_REQUEST_TIMEOUT,+ }response = client.request(method, url, **request_kwargs)@@ -206,9 +209,8 @@ class EnterpriseRequest(BaseRequest):"json": json,"params": params,"headers": {"Content-Type": "application/json", cls.secret_key_header: cls.secret_key, **inner_headers},+ "timeout": timeout if timeout is not None else dify_config.ENTERPRISE_RBAC_REQUEST_TIMEOUT,}- if timeout is not None:- request_kwargs["timeout"] = timeoutresponse = client.request(method, url, **request_kwargs)if not response.is_success:cls._handle_error_response(response)