Skip to content

fix(user): Pydantic 校验失败 - external_credentials.usp.username 为 null - #404

Merged
Rosshow merged 1 commit into
testfrom
fix/user-external-credentials-null
Oct 27, 2026
Merged

Rosshow merged 1 commit into
testfrom
fix/user-external-credentials-null

Conversation

@Nemenisi

Copy link
Copy Markdown
Collaborator
  • 放宽 schemas/user.py 中 4 个 schema 的 external_credentials 类型约束 从 Dict[str, Dict[str, str]] 改为 Dict[str, Dict[str, Any]],允许嵌套 None
  • 在 identity_service 层新增 normalize_external_credentials() 清洗函数, 作为 service 层单一拦截点,覆盖 _user_dict 读路径和 update_user 写路径
  • 在 admin/api/users.py 中同样添加 _normalize_external_credentials, 覆盖 get_users/create_user/update_user/update_user_uspinfo 所有 User 构造点
  • 修复 update_user 中 existing_usp.get(username) 返回 None 又写回 DB 的循环污染 bug(增加 is not None 哨兵判断)
  • database.py / identity_service.py 的 add_user 参数注解同步放宽

- 放宽 schemas/user.py 中 4 个 schema 的 external_credentials 类型约束
  从 Dict[str, Dict[str, str]] 改为 Dict[str, Dict[str, Any]],允许嵌套 None
- 在 identity_service 层新增 normalize_external_credentials() 清洗函数,
  作为 service 层单一拦截点,覆盖 _user_dict 读路径和 update_user 写路径
- 在 admin/api/users.py 中同样添加 _normalize_external_credentials,
  覆盖 get_users/create_user/update_user/update_user_uspinfo 所有 User 构造点
- 修复 update_user 中 existing_usp.get(username) 返回 None 又写回 DB
  的循环污染 bug(增加 is not None 哨兵判断)
- database.py / identity_service.py 的 add_user 参数注解同步放宽
@Rosshow
Rosshow merged commit dfabf48 into test Oct 27, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants