Skip to content

armgit / dify

Public Imported from GitHub
0

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.

Fix token expiry miscalculation (#24639)

Yongtao Huangbb718acadf18
diff --git a/api/extensions/ext_storage.py b/api/extensions/ext_storage.py
index d13393dd142..2960cde2428 100644
--- a/api/extensions/ext_storage.py
+++ b/api/extensions/ext_storage.py
@@ -65,7 +65,7 @@ class Storage:
from extensions.storage.volcengine_tos_storage import VolcengineTosStorage
return VolcengineTosStorage
- case StorageType.SUPBASE:
+ case StorageType.SUPABASE:
from extensions.storage.supabase_storage import SupabaseStorage
return SupabaseStorage
diff --git a/api/extensions/storage/storage_type.py b/api/extensions/storage/storage_type.py
index bc2d6321596..baffa423b60 100644
--- a/api/extensions/storage/storage_type.py
+++ b/api/extensions/storage/storage_type.py
@@ -14,4 +14,4 @@ class StorageType(StrEnum):
S3 = "s3"
TENCENT_COS = "tencent-cos"
VOLCENGINE_TOS = "volcengine-tos"
- SUPBASE = "supabase"
+ SUPABASE = "supabase"
diff --git a/api/factories/variable_factory.py b/api/factories/variable_factory.py
index aa9828f3db5..0274b6e89c4 100644
--- a/api/factories/variable_factory.py
+++ b/api/factories/variable_factory.py
@@ -128,10 +128,6 @@ def _build_variable_from_mapping(*, mapping: Mapping[str, Any], selector: Sequen
return cast(Variable, result)
-def infer_segment_type_from_value(value: Any, /) -> SegmentType:
- return build_segment(value).value_type
-
-
def build_segment(value: Any, /) -> Segment:
# NOTE: If you have runtime type information available, consider using the `build_segment_with_type`
# below
diff --git a/api/libs/helper.py b/api/libs/helper.py
index d4f15ca9370..96e85246605 100644
--- a/api/libs/helper.py
+++ b/api/libs/helper.py
@@ -301,8 +301,8 @@ class TokenManager:
if expiry_minutes is None:
raise ValueError(f"Expiry minutes for {token_type} token is not set")
token_key = cls._get_token_key(token, token_type)
- expiry_time = int(expiry_minutes * 60)
- redis_client.setex(token_key, expiry_time, json.dumps(token_data))
+ expiry_seconds = int(expiry_minutes * 60)
+ redis_client.setex(token_key, expiry_seconds, json.dumps(token_data))
if account_id:
cls._set_current_token_for_account(account_id, token, token_type, expiry_minutes)
@@ -336,11 +336,11 @@ class TokenManager:
@classmethod
def _set_current_token_for_account(
- cls, account_id: str, token: str, token_type: str, expiry_hours: Union[int, float]
+ cls, account_id: str, token: str, token_type: str, expiry_minutes: Union[int, float]
):
key = cls._get_account_token_key(account_id, token_type)
- expiry_time = int(expiry_hours * 60 * 60)
- redis_client.setex(key, expiry_time, token)
+ expiry_seconds = int(expiry_minutes * 60)
+ redis_client.setex(key, expiry_seconds, token)
@classmethod
def _get_account_token_key(cls, account_id: str, token_type: str) -> str: