🐛 Bugfix: Fixed an issue where the created_by field was not written when publishing an agent version.#3287
Merged
Merged
Conversation
… when publishing an agent version.
WMC001
approved these changes
Jun 24, 2026
JasonW404
reviewed
Jun 24, 2026
| data.pop('update_time', None) | ||
| data.pop('created_by', None) | ||
| data.pop('updated_by', None) | ||
| data.pop('delete_flag', None) |
Member
There was a problem hiding this comment.
_remove_audit_fields_for_insert 不再移除 created_by,意味着发布版本时会将草稿的 created_by 原样复制到快照中。如果发布者和创建者不同(如管理员代发),快照的 created_by 会指向原始创建者而非发布者。确认这是期望行为?如果需要区分,应保留 created_by 的移除并单独设置。
Contributor
Author
🔍 Code Review Comments1. [逻辑漏洞] 审计字段保留的副作用 2. [代码规范] 缺少统一的审计字段 helper |
YehongPan
commented
Jun 24, 2026
YehongPan
left a comment
Contributor
Author
There was a problem hiding this comment.
Code Review
- [逻辑漏洞]
_remove_audit_fields_for_insert中移除了data.pop('created_by', None)和data.pop('updated_by', None),这意味着所有 snapshot 插入都会保留原始审计字段。对于从旧版本回滚的场景,created_by可能指向已删除用户。 - [代码规范]
publish_version_impl中手动为每个 snapshot 类型设置updated_by = user_id,代码重复度高(agent/tool/relation/skill 各一处)。建议抽取统一的_stamp_audit_fields(snapshot, user_id)helper 函数,降低后续维护遗漏风险。
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.
🐛 Bugfix: Fixed an issue where the



created_byfield was not written when publishing an agent version.close #3286
[Test Result]