Skip to content

Commit

Permalink
refactor: cr调整
Browse files Browse the repository at this point in the history
  • Loading branch information
neronkl committed Sep 23, 2023
1 parent aab16ea commit b544c37
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/api/bkuser_core/api/web/profile/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def _update(self, request, partial):
try:
instance.save()
except Exception as e: # pylint: disable=broad-except
logger.exception("failed to update profile, exception: %s", e)
username = f"{instance.username}@{instance.domain}"
logger.exception(f"failed to update profile<{username}>")
raise error_codes.SAVE_USER_INFO_FAILED.f(exception_message=e)

post_profile_update.send(
Expand Down
7 changes: 4 additions & 3 deletions src/api/bkuser_core/profiles/v2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,10 @@ def _update(self, request, partial):

try:
instance.save()
except Exception: # pylint: disable=broad-except
logger.exception("failed to update profile")
return error_codes.SAVE_USER_INFO_FAILED
except Exception as e: # pylint: disable=broad-except
username = f"{instance.username}@{instance.domain}"
logger.exception(f"failed to update profile<{username}>")
raise error_codes.SAVE_USER_INFO_FAILED.f(exception_message=e)

post_profile_update.send(
sender=self,
Expand Down
8 changes: 8 additions & 0 deletions src/api/bkuser_core/profiles/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def validate_extras_value_unique(value: dict, category_id: int, profile_id: int
):
# 防御: 可能存在部分旧数据并未添加所有 extra key
if f.name not in s.extras:
logging.info(
"profile<%s@%s> has the same value<%s> of field<%s-%s>",
s.username,
s.domain,
target_value,
f.name,
f.display_name,
)
continue

if s.extras[f.name] == target_value:
Expand Down

0 comments on commit b544c37

Please sign in to comment.