Skip to content

fix(genericapi): update summary, details and metadata on dedup match#4514

Open
C2L2C wants to merge 2 commits into
target:masterfrom
C2L2C:fix/generic-api-update-and-escalate
Open

fix(genericapi): update summary, details and metadata on dedup match#4514
C2L2C wants to merge 2 commits into
target:masterfrom
C2L2C:fix/generic-api-update-and-escalate

Conversation

@C2L2C

@C2L2C C2L2C commented Jun 22, 2026

Copy link
Copy Markdown

Problem

Fixes #4374

When the Generic Alert Ingestion API receives a POST with a dedup key matching an existing alert, it returns 200 IsNew:false but silently discards the incoming summary, details, and metadata.

Root Cause

Two bugs in alert/store.go:

  1. CreateOrUpdateTx — the createUpdNew SQL CTE returns the existing row unchanged. New summary/details are only used in the INSERT branch; the existing-alert branch ignores them entirely.

  2. createOrUpdateSetMetadataTx was guarded by && isNew, so metadata was only written for brand-new alerts.

Changes

  • alert/store.go: After a dedup match on a non-closed alert, run a second UPDATE statement to apply new summary/details. Remove && isNew guard on metadata so it updates for existing alerts too.
  • alert/store.go: Extend EscalateAsOf to accept permission.Service with an ownership check, so services can re-escalate their own alerts via the API.
  • genericapi/handler.go: Add escalate parameter (form value, query string, or JSON body). When true on an existing alert, re-triggers the escalation policy.
  • test/smoke/genericapiupdate_test.go: Smoke test covering summary + metadata update via dedup key, and re-escalation via escalate:true.

Testing

go test ./test/smoke/ -run TestGenericAPIUpdate -v -timeout 120s
--- PASS: TestGenericAPIUpdate (11.38s)

Notes

  • Alert metadata is not currently rendered in the UI. It is stored in the DB and accessible via GraphQL but has no UI surface — worth a follow-up issue.
  • JSON body requires "escalate":true (boolean). Form-encoded requests accept escalate=true (string).

  Previously the generic ingestion API returned IsNew:false when a dedup
  key matched an existing alert but silently discarded the incoming
  summary, details and metadata.

  - Run UPDATE after dedup SELECT so summary/details are persisted
  - Remove isNew guard on SetMetadataTx so metadata updates too
  - Add escalate param (form/query/JSON) to re-trigger escalation policy
  - Extend EscalateAsOf to accept service permission with ownership check

Signed-off-by: Aditya Sharma <glennadi007@gmail.com>
@C2L2C C2L2C force-pushed the fix/generic-api-update-and-escalate branch from b85b235 to 6e4d2bf Compare June 22, 2026 10:52
Previously meta was initialized as make(map[string]string) in the
handler (never nil), so the nil check always passed and SetMetadataTx
was called on every request including closes. This caused a 403 when
closing an alert because SetMetadataTx returns access denied when the
alert is already closed.

Fix by checking len(meta) > 0 instead of meta != nil.

Signed-off-by: Aditya Sharma <glennadi007@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Generic Alert Ingestion API does not update an existing alert

1 participant