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.

refactor(api): reuse IdentityDict TypedDict in logging filters (#34593)

YBoy01ba0e050f33
diff --git a/api/core/logging/filters.py b/api/core/logging/filters.py
index 1e8aa8d566b..dee1432363c 100644
--- a/api/core/logging/filters.py
+++ b/api/core/logging/filters.py
@@ -6,6 +6,7 @@ import logging
import flask
from core.logging.context import get_request_id, get_trace_id
+from core.logging.structured_formatter import IdentityDict
class TraceContextFilter(logging.Filter):
@@ -60,7 +61,7 @@ class IdentityContextFilter(logging.Filter):
record.user_type = identity.get("user_type", "")
return True
- def _extract_identity(self) -> dict[str, str]:
+ def _extract_identity(self) -> IdentityDict:
"""Extract identity from current_user if in request context."""
try:
if not flask.has_request_context():
@@ -77,7 +78,7 @@ class IdentityContextFilter(logging.Filter):
from models import Account
from models.model import EndUser
- identity: dict[str, str] = {}
+ identity: IdentityDict = {}
if isinstance(user, Account):
if user.current_tenant_id: