Skip to content

fix: decode alert pipelines that carry an if condition - #64

Merged
ysyneu merged 1 commit into
mainfrom
fix/pipeline-if-and-list
Aug 25, 2026
Merged

fix: decode alert pipelines that carry an if condition#64
ysyneu merged 1 commit into
mainfrom
fix/pipeline-if-and-list

Conversation

@ysyneu

@ysyneu ysyneu commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Regenerated from the corrected spec (flashduty-docs #307 + #308).

AlertPipeline.If and ApAlertInhibit.SourceFilters were generated as OrFilterGroup ([][]FilterCondition), but the server models both as a single AND group — a flat list. Any pipeline carrying an if condition failed to decode:

json: cannot unmarshal object into Go struct field
AlertPipeline.rules.if of type []FilterCondition

Both are now []FilterCondition. OrFilterGroup is untouched — the silence / inhibit / drop / escalation rules that use it really are OR-of-AND.

Also picked up by the spec refresh (landed upstream since the last sync, unrelated to the decode fix):

  • CreateDropRuleRequest.Priority / UpdateDropRuleRequest.Priority removed — drop rules have no priority server-side.
  • KnowledgePackItem.DutyVersion added.

Verification — the spec examples now carry a real if shape, so TestSpecExamplesRoundTrip actually exercises both fields:

  • against the previous OrFilterGroup types it fails on /alert/pipeline/info and /alert/pipeline/list with the exact error above;
  • against these types it passes. Full go test ./... green.

`AlertPipeline.If` and `ApAlertInhibit.SourceFilters` were generated as
`OrFilterGroup` ([][]FilterCondition), but the server models both as a
single AND group — a flat list. Any pipeline with an `if` condition
therefore failed to decode:

  json: cannot unmarshal object into Go struct field
  AlertPipeline.rules.if of type []FilterCondition

Both are now `[]FilterCondition`. `OrFilterGroup` is untouched — the
silence / inhibit / drop / escalation rules that use it really are
OR-of-AND.

The refreshed spec also carries two unrelated corrections that landed
upstream since the last sync:

- `CreateDropRuleRequest.Priority` / `UpdateDropRuleRequest.Priority`
  are gone; drop rules have no priority server-side.
- `KnowledgePackItem.DutyVersion` is new.

The pipeline examples in the spec now carry a real `if` shape, so
TestSpecExamplesRoundTrip covers both fields — it fails against the old
types and passes against these.
@ysyneu
ysyneu merged commit 1a52030 into main Aug 25, 2026
4 checks passed
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.

1 participant