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: account.id should account_id (#11628)

yihong8e3d60c3597d
diff --git a/api/libs/helper.py b/api/libs/helper.py
index 7652d73c8b8..026ded35068 100644
--- a/api/libs/helper.py
+++ b/api/libs/helper.py
@@ -9,11 +9,11 @@ import uuid
from collections.abc import Generator, Mapping
from datetime import datetime
from hashlib import sha256
-from typing import Any, Optional, Union
+from typing import Any, Optional, Union, cast
from zoneinfo import available_timezones
from flask import Response, stream_with_context
-from flask_restful import fields
+from flask_restful import fields # type: ignore
from configs import dify_config
from core.app.features.rate_limiting.rate_limit import RateLimitGenerator
@@ -168,11 +168,11 @@ def generate_string(n):
def extract_remote_ip(request) -> str:
if request.headers.get("CF-Connecting-IP"):
- return request.headers.get("Cf-Connecting-Ip")
+ return cast(str, request.headers.get("Cf-Connecting-Ip"))
elif request.headers.getlist("X-Forwarded-For"):
- return request.headers.getlist("X-Forwarded-For")[0]
+ return cast(str, request.headers.getlist("X-Forwarded-For")[0])
else:
- return request.remote_addr
+ return cast(str, request.remote_addr)
def generate_text_hash(text: str) -> str:
@@ -221,12 +221,14 @@ class TokenManager:
token_data.update(additional_data)
expiry_minutes = dify_config.model_dump().get(f"{token_type.upper()}_TOKEN_EXPIRY_MINUTES")
+ 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))
if account_id:
- cls._set_current_token_for_account(account.id, token, token_type, expiry_minutes)
+ cls._set_current_token_for_account(account_id, token, token_type, expiry_minutes)
return token