From 40655d63e09a4dc3158d68952dadf1a23d40c1de Mon Sep 17 00:00:00 2001 From: seaislee1209 Date: Sat, 28 Mar 2026 21:40:06 +0800 Subject: [PATCH] fix: detect ghost LoginProfile from Volcengine (CreateDate=1970) Users created without console password have a phantom LoginProfile that GetLoginProfile returns but UpdateLoginProfile/DeleteLoginProfile reject. Now checking CreateDate to detect this. Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/utils/iam_service.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/utils/iam_service.py b/backend/utils/iam_service.py index 3bb63d2..4b4f03f 100644 --- a/backend/utils/iam_service.py +++ b/backend/utils/iam_service.py @@ -198,9 +198,14 @@ class IAMService: pass def _has_login_profile(self, username: str) -> bool: - """检查用户是否有 LoginProfile""" + """检查用户是否有真实的 LoginProfile(火山可能返回空壳)""" try: - self.get_login_profile(username) + resp = self.get_login_profile(username) + profile = resp.get("Result", {}).get("LoginProfile", {}) + # Empty shell has CreateDate=19700101 and Password="" + create_date = profile.get("CreateDate", "") + if create_date.startswith("1970") or create_date.startswith("0001"): + return False return True except VolcengineAPIError as e: if "LoginProfileNotExist" in str(e) or "RecordNotFound" in str(e):