fix: handle PolicyAttachConflict when adding project policies
Global policies conflict with project-level attach - treat as success since the user already has the permission globally. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cc8a91995d
commit
6dd3ac5c0d
@ -610,7 +610,11 @@ def iam_user_project_add_view(request, pk):
|
||||
d['project_name'])
|
||||
attached.append(policy_name)
|
||||
except VolcengineAPIError as e:
|
||||
auth_errors.append(f"{policy_name}: {e}")
|
||||
if 'PolicyAttachConflict' in str(e):
|
||||
# 全局已有此策略,项目级无需重复附加,视为成功
|
||||
attached.append(policy_name)
|
||||
else:
|
||||
auth_errors.append(f"{policy_name}: {e}")
|
||||
|
||||
obj.attached_policies = attached
|
||||
obj.save(update_fields=['attached_policies'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user