Repository navigation
fix(user): Pydantic 校验失败 - external_credentials.usp.username 为 null - #404
Merged
Merged
Conversation
Nemenisi
commented
Oct 27, 2026
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
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.