Skip to content

🐛 Bugfix: Fixed an issue where the created_by field was not written when publishing an agent version.#3287

Merged
WMC001 merged 1 commit into
developfrom
pyh/fix_agent_publish_develop
Jun 24, 2026
Merged

🐛 Bugfix: Fixed an issue where the created_by field was not written when publishing an agent version.#3287
WMC001 merged 1 commit into
developfrom
pyh/fix_agent_publish_develop

Conversation

@YehongPan

Copy link
Copy Markdown
Contributor

🐛 Bugfix: Fixed an issue where the created_by field was not written when publishing an agent version.
close #3286
[Test Result]
image
image
image

@WMC001 WMC001 merged commit 9d2ef87 into develop Jun 24, 2026
12 checks passed
data.pop('update_time', None)
data.pop('created_by', None)
data.pop('updated_by', None)
data.pop('delete_flag', None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_remove_audit_fields_for_insert 不再移除 created_by,意味着发布版本时会将草稿的 created_by 原样复制到快照中。如果发布者和创建者不同(如管理员代发),快照的 created_by 会指向原始创建者而非发布者。确认这是期望行为?如果需要区分,应保留 created_by 的移除并单独设置。

@YehongPan

Copy link
Copy Markdown
Contributor Author

🔍 Code Review Comments

1. [逻辑漏洞] 审计字段保留的副作用
_remove_audit_fields_for_insert 中移除了 data.pop('created_by', None)data.pop('updated_by', None),这意味着所有 snapshot 插入都会保留原始审计字段。对于从旧版本回滚的场景,created_by 可能指向已删除用户。

2. [代码规范] 缺少统一的审计字段 helper
publish_version_impl 中手动为每个 snapshot 类型设置 updated_by = user_id,代码重复度高(agent/tool/relation/skill 各一处)。建议抽取统一的 _stamp_audit_fields(snapshot, user_id) helper 函数,降低后续维护遗漏风险。

@YehongPan YehongPan left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 函数,降低后续维护遗漏风险。

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.

3 participants