Assign/archive/unarchive track no actor at all (for anyone, human or service account) #35
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Follow-up to #25. While fixing #25 (service-account callers 500ing on incident-mutation
routes), it became clear three handlers in
internal/api/incidents.gotrack no actor atall today, for a human either, let alone a service account:
handleIncidentAssign— writesassigned_to(who the incident is assigned to) and logsan
evAssignedtimeline event keyed onreq.UserID, the assignee. The actor — whoperformed the assignment — is nowhere. The existing code comment says as much: "On an
'assigned' event user_id is the assignee, not the actor."
handleIncidentArchive/handleIncidentUnarchive— fliparchived_atand call nologEventat all. There is no timeline entry and no actor for either operation, for anyone.None of these 500 for a service account (there's no FK write to violate), so they were
correctly left out of #25's scope — but they're a real, pre-existing symmetry gap: every
other incident-mutation route (acknowledge, resolve, snooze, note) now records who acted,
distinctly for a human vs. a service account, and these three don't.
Suggested fix (not prescriptive)
handleIncidentArchive/handleIncidentUnarchive: addlogEvent(..., evArchived/evUnarchived, userID, saID, nil, nil)calls using thecallerActorIDs(ctx)helper #25 added ininternal/api/incident_store.go. Needs newevArchived/evUnarchivedevent-type constants(
internal/api/incident_store.go'sconstblock) and corresponding web UI(
internal/web/static/js/incident.js'seventText) / TUI timeline rendering for them.handleIncidentAssign: recording the actor needs a schema decision analogous to #25's —either a new
assigned_by/assigned_by_service_account_idpair of columns, or folding actorattribution into the existing
evAssignedevent'sdetailrather than itsuser_id(whichmust stay the assignee). If a column is added, this is also the natural point to add
assigned_to_service_account_id(deliberately deferred in #25's migration 015, since nothingpopulated it yet) — i.e. service accounts should become assignable too, not just actors.
Also deferred from #25
terdut-tuirendering: #25 addedacknowledged_by_service_account_id/acknowledged_by_service_account(onIncident) andservice_account_id/service_account_name(onIncidentEvent) to the server's JSON. They're additive/omitempty,so the TUI's existing parsing in
internal/api/types.gois unaffected either way — but theTUI has no code to display them, so a human TUI user viewing an incident a service account
acted on sees no actor at all today (same degraded-but-not-wrong behavior the web UI had
before #25). Worth doing once this issue's columns settle, so both gaps get TUI parity in one
pass rather than two.
References
internal/api/incidents.go—handleIncidentAssign(~line 285),handleIncidentArchive/handleIncidentUnarchive(~line 400).internal/api/incident_store.go—callerActorIDs,logEvent, theev*constants (added/extended by #25).
015_incident_service_account_actors.sql.Implemented on
main(not yet pushed or released).Done
018_incident_event_actor.sql:incident_events.actor_user_id/actor_service_account_id(exclusive,ON DELETE SET NULL). Used only forassignedevents, whereuser_idstays the assignee. Older assignments have no actor.handleIncidentAssignrecords the caller as actor (human or service account).archived/unarchivedevents with the caller.actor_user_id,actor_username,actor_service_account_id,actor_service_account_name(omitempty); web timeline shows "Assigned to X by Y" and archive/unarchive entries; README updated.make fmt lint test helm-lintis green.Deferred
assigned_to_service_account_id): that changes the assign request body, the assignee picker, the notifier and theassigned_tofilter, so it should be its own issue.terdut-tuirendering of the #25 fields (service_account*) and the newactor_*fields andarchived/unarchivedevents. The additions are additive, so the TUI keeps working meanwhile.Shipped in v0.39.0 (image published, trivy scan clean). Deploy is pending the wrapper-chart PR: Ryuvia/charts#299. Closing. The two deferred items (assignable service accounts, and
terdut-tuirendering of the actor fields) still need their own issues.