From 5be531764c4bbb8efe630278076f678b2040e643 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Wed, 25 Dec 2024 18:24:59 +0800 Subject: [PATCH 1/2] fix(billing_service): change retry condition to handle specific request errors Signed-off-by: -LAN- --- api/services/billing_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/services/billing_service.py b/api/services/billing_service.py index d98018648839a9..ed611a8be48679 100644 --- a/api/services/billing_service.py +++ b/api/services/billing_service.py @@ -2,7 +2,7 @@ from typing import Optional import httpx -from tenacity import retry, retry_if_not_exception_type, stop_before_delay, wait_fixed +from tenacity import retry, retry_if_exception_type, stop_before_delay, wait_fixed from extensions.ext_database import db from models.account import TenantAccountJoin, TenantAccountRole @@ -44,7 +44,7 @@ def get_invoices(cls, prefilled_email: str = "", tenant_id: str = ""): @retry( wait=wait_fixed(2), stop=stop_before_delay(10), - retry=retry_if_not_exception_type(httpx.RequestError), + retry=retry_if_exception_type(httpx.RequestError), reraise=True, ) def _send_request(cls, method, endpoint, json=None, params=None): From e44230d8fe0889d35e1b43c4f700b769f8401b72 Mon Sep 17 00:00:00 2001 From: Garfield Dai Date: Wed, 25 Dec 2024 18:38:45 +0800 Subject: [PATCH 2/2] fix: check tenant_id --- api/services/feature_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 0386c6aceaa2e7..b9261d19d7930e 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -74,7 +74,7 @@ def get_features(cls, tenant_id: str) -> FeatureModel: cls._fulfill_params_from_env(features) - if dify_config.BILLING_ENABLED: + if dify_config.BILLING_ENABLED and tenant_id: cls._fulfill_params_from_billing_api(features, tenant_id) return features