mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 09:58:04 +08:00
log expiration_date=-1
This commit is contained in:
@ -42,6 +42,7 @@ class BillingService:
|
|||||||
params = {"tenant_id": tenant_id}
|
params = {"tenant_id": tenant_id}
|
||||||
|
|
||||||
billing_info = cls._send_request("GET", "/subscription/info", params=params)
|
billing_info = cls._send_request("GET", "/subscription/info", params=params)
|
||||||
|
cls._log_expiration_date_if_missing(tenant_id, billing_info, "get_info")
|
||||||
return billing_info
|
return billing_info
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -281,6 +282,7 @@ class BillingService:
|
|||||||
try:
|
try:
|
||||||
subscription_plan = subscription_adapter.validate_python(plan)
|
subscription_plan = subscription_adapter.validate_python(plan)
|
||||||
results[tenant_id] = subscription_plan
|
results[tenant_id] = subscription_plan
|
||||||
|
cls._log_expiration_date_if_missing(tenant_id, subscription_plan, "get_plan_bulk")
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"get_plan_bulk: failed to validate subscription plan for tenant(%s)", tenant_id
|
"get_plan_bulk: failed to validate subscription plan for tenant(%s)", tenant_id
|
||||||
@ -296,6 +298,21 @@ class BillingService:
|
|||||||
def _make_plan_cache_key(cls, tenant_id: str) -> str:
|
def _make_plan_cache_key(cls, tenant_id: str) -> str:
|
||||||
return f"{cls._PLAN_CACHE_KEY_PREFIX}{tenant_id}"
|
return f"{cls._PLAN_CACHE_KEY_PREFIX}{tenant_id}"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _log_expiration_date_if_missing(tenant_id: str, payload: dict, source: str) -> None:
|
||||||
|
expiration_date = None
|
||||||
|
if isinstance(payload, dict):
|
||||||
|
if "expiration_date" in payload:
|
||||||
|
expiration_date = payload.get("expiration_date")
|
||||||
|
elif isinstance(payload.get("subscription"), dict):
|
||||||
|
expiration_date = payload["subscription"].get("expiration_date")
|
||||||
|
if expiration_date == -1:
|
||||||
|
logger.warning(
|
||||||
|
"billing %s: tenant %s returned expiration_date=-1",
|
||||||
|
source,
|
||||||
|
tenant_id,
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_plan_bulk_with_cache(cls, tenant_ids: Sequence[str]) -> dict[str, SubscriptionPlan]:
|
def get_plan_bulk_with_cache(cls, tenant_ids: Sequence[str]) -> dict[str, SubscriptionPlan]:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user