Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix tiny issues (#14006)

Jin Haie2b879b2588b
diff --git a/api/apps/__init__.py b/api/apps/__init__.py
index 4cf5b9e230..172d907fe9 100644
--- a/api/apps/__init__.py
+++ b/api/apps/__init__.py
@@ -121,11 +121,12 @@ def _load_user():
g.user = user[0]
return user[0]
except Exception as e_auth:
- logging.warning(f"load_user got exception {e_auth}")
+ logging.warning(f"load_user from jwt got exception {e_auth}")
try:
authorization = request.headers.get("Authorization")
if len(authorization.split()) == 2:
- objs = APIToken.query(token=authorization.split()[1])
+ token = authorization.split()[1]
+ objs = APIToken.query(token=token)
if objs:
user = UserService.query(id=objs[0].tenant_id, status=StatusEnum.VALID.value)
if user:
@@ -134,8 +135,12 @@ def _load_user():
return None
g.user = user[0]
return user[0]
+ else:
+ logging.warning(f"load_user: No user found for tenant_id={objs[0].tenant_id} from APIToken")
+ else:
+ logging.warning(f"load_user: No APIToken found for token={token[:10]}...")
except Exception as e_api_token:
- logging.warning(f"load_user got exception {e_api_token}")
+ logging.warning(f"load_user from api token got exception {e_api_token}")
# Fallback: try raw authorization value as access_token (for login tokens sent without JWT)
try:
authorization = request.headers.get("Authorization")
diff --git a/api/db/services/user_canvas_version.py b/api/db/services/user_canvas_version.py
index 4224dd6a1f..faaca89d10 100644
--- a/api/db/services/user_canvas_version.py
+++ b/api/db/services/user_canvas_version.py
@@ -11,6 +11,7 @@ from peewee import DoesNotExist
class UserCanvasVersionService(CommonService):
model = UserCanvasVersion
+ # Build a stable display name for saved snapshots.
@staticmethod
def build_version_title(user_nickname, agent_title, ts=None):
tenant = str(user_nickname or "").strip() or "tenant"
@@ -18,6 +19,7 @@ class UserCanvasVersionService(CommonService):
stamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts)) if ts is not None else time.strftime("%Y-%m-%d %H:%M:%S")
return "{0}_{1}_{2}".format(tenant, title, stamp)
+ # Normalize DSL before comparing or writing version content.
@staticmethod
def _normalize_dsl(dsl):
normalized = dsl
@@ -143,6 +145,7 @@ class UserCanvasVersionService(CommonService):
.first()
)
+ # Repeated saves with the same DSL only refresh the latest snapshot.
if latest and cls._normalize_dsl(latest.dsl) == normalized_dsl:
# Protect released version: if latest is released and current is not,
# create a new version instead of updating
@@ -170,6 +173,7 @@ class UserCanvasVersionService(CommonService):
cls.delete_all_versions(user_canvas_id)
return latest.id, False
+ # Real content changes create a new snapshot.
insert_data = {"user_canvas_id": user_canvas_id, "dsl": normalized_dsl}
if title is not None:
insert_data["title"] = title