Audit log shows a blank user for API key, system, and deleted-user changes
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
调研方向
先从 api/audit/serializers.py 和 frontend/web/components/AuditLog.tsx 开始,然后比较 api/features/tasks.py 中 trigger_feature_state_change_webhooks 的归属处理方式。完成的标准是 API 响应公开 master API key 的归属信息,并且 UI 能区分作者、API key、系统事件和已删除用户,不出现空的 User 单元格;已删除用户的行为仍需要进行数据决策。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem?
Audit log entries frequently show an empty User column, with no indication of who or what made the change. A customer raised this on SaaS: "Sometimes no user is listed in the user section in the audit log. Do you know why this happens?"
There are three ways an entry ends up with author = null:
- The change was made with a Master API Key (Terraform provider, CI scripts, direct Admin API calls).
AuditLoghas a separatemaster_api_keyFK alongsideauthor, and it is populated correctly - we just never return it.AuditLogListSerializerandAuditLogRetrieveSerializeronly exposeauthor, so the API response has no attribution at all for these entries. - System events (
is_system_event=True), e.g. a scheduled Change Request going live viacreate_feature_state_went_live_audit_log. These legitimately have no human author, but the UI gives no signal that this is why the field is blank. - The user was deleted.
authorison_delete=models.SET_NULL, so removing a member from the organisation retroactively blanks their name on every historical entry they created.
In the UI this is worse than in the API, because AuditLog.tsx renders {author?.first_name} {author?.last_name} with no fallback - so all three cases render as an empty cell that looks like missing data rather than a known state.
The impact is that the audit log stops being a reliable answer to "who changed this flag", which is its primary job. For customers using it for compliance or for tracing an unexpected production change, a blank cell is indistinguishable from a bug. Note that is_system_event is already returned by the API and unused by the row rendering, and master_api_key attribution already exists in the database - so in both cases the information is present and simply not surfaced.
Describe the solution you'd like.
Never render an empty User cell. Specifically:
- Add the Master API Key to the audit log serializers (at minimum
{id, name}fromMasterAPIKey) so API consumers can attribute API-driven changes. - In
AuditLog.tsx, fall back throughauthor-> master API key name (badged as an API key, e.g.🔑 terraform-prod) ->Systemwhenis_system_eventis true. - For deleted users, show something explicit such as
Deleted userrather than nothing. This one needs a data decision - see alternatives.
Item 1 and 2 are small and independent of item 3, and together cover the majority of reported blanks.
Describe alternatives you've considered
- Denormalise the author's email onto
AuditLogat write time. This solves case 3 properly (the historical record keeps the identity of whoever made the change, even after the user is deleted) but is a larger change and has GDPR implications for erasure requests, so it deserves its own discussion. RenderingDeleted useris the cheaper option and at least distinguishes "we don't know" from "no human did this". - Leave the API as-is and fix only the frontend. Rejected: customers query the audit log API directly for SIEM and compliance pipelines, and the attribution gap exists there too.
- Document the behaviour instead of changing it. Doesn't help - the reason a user asks about this is that they need to know who made a specific change, and documentation doesn't give them the answer.
Additional context
Relevant code:
api/audit/models.py-AuditLog.author(SET_NULL),AuditLog.master_api_key,AuditLog.is_system_eventapi/audit/serializers.py-AuditLogListSerializer/AuditLogRetrieveSerializerfield lists, neither includesmaster_api_keyapi/audit/tasks.py-_create_feature_state_audit_log_for_change_requestcreatesis_system_event=Trueentries with no authorfrontend/web/components/AuditLog.tsx- renders{author?.first_name} {author?.last_name}with no fallback
Worth noting that the flag change webhook already handles this correctly: trigger_feature_state_change_webhooks in api/features/tasks.py falls back to master_api_key.name for changed_by. So a customer receiving webhooks currently gets better attribution than the same customer reading the audit log UI. Aligning the audit log with that existing behaviour seems like the obvious baseline.
Possibly relevant to #6304 (Epic: Audit Log Enhancements).
Raised from a SaaS customer support conversation.
- 主要语言
- Python
- 星标
- 9.9k
- 派生
- 658
- 平均合并
- 1 天 15 小时
- 30 天内合并 PR
- 171
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Flagsmith/flagsmith 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
Flagsmith/flagsmith#9119 · 1 条评论 ·
维护者通常 1 天内回复
-
Fix Button Alignment in SDK Installation Section可能已有人在做 @manueldezman 于 4 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 62/100
Flagsmith/flagsmith#9056 · 2 条评论 ·
维护者通常 1 天内回复
-
Cloud Python warehouse snippet omits the import needed by its short-lived-job guidance可能已有人在做 @jcd1991 于 5 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 75/100
Flagsmith/flagsmith#9045 · 1 条评论 ·
维护者通常 1 天内回复
-
Expose whether an organisation is blocked for API usage可能已有人在做 @PiUnknown 于 39 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
Flagsmith/flagsmith#8773 · 1 条评论 ·
维护者通常 1 天内回复
查看 Flagsmith/flagsmith 的全部 Issue
相似的 Issue
-
documentation good first issue help wanted
难度 1/5 1 小时以内 新手友好度 90/100
-
documentation good first issue help wanted
难度 1/5 1 小时以内 新手友好度 88/100
-
documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 72/100
collabnix/awesome-mcp-lists#490 ·
维护者通常 2 天内回复