Skip to content

fix: flux appsignal incidents list, get and resources read the server's responses - #27

Merged
mellelieuwes merged 3 commits into
masterfrom
hp/flux/t-0079-incidents-list-decode
Oct 28, 2026
Merged

mellelieuwes merged 3 commits into
masterfrom
hp/flux/t-0079-incidents-list-decode

Conversation

@mellelieuwes

@mellelieuwes mellelieuwes commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Flux issue: https://app.basecamp.com/5734045/buckets/45557517/todos/10448800497

Problem

The CLI's AppSignal read commands (v0.6.0) don't work against flux-test or production:

  • flux appsignal incidents list fails with failed to decode response: json: cannot unmarshal object into Go struct field IncidentsResponse.incidents of type []api.Incident.
  • flux appsignal incidents get <N> prints an empty # Incident #N: / State:.
  • flux appsignal resources prints nothing.

Cause

The CLI drifted. The server hasn't changed: since the AppSignal endpoints were added (eyra/flux c8aa577, 2026-02-05), each one wraps AppSignal's MCP text (Markdown) as content:

  • GET …/appsignal/incidents, --type exception or anomaly: {"incidents": {"type": "exception", "content": "# Exception Incidents\n…"}}
  • GET …/appsignal/incidents, all types (the default): {"incidents": {"exceptions": {…}, "anomalies": {…}}}
  • GET …/appsignal/incidents/:number: {"number": 121, "content": "# Incident #121: ArgumentError\n…"}
  • GET …/appsignal/resources: {"sections": ["users", …], "content": "# Application Resources\n…"}

The CLI's AppSignal commands (5910d69, 2026-06-17) were written against structured incidents and resources that no server version ever sent.

Fix (CLI only)

  • The CLI decodes these four shapes and prints AppSignal's Markdown as is. Listings come exceptions first, and AppSignal's own "no incidents found" text comes through.
  • --json:
    • incidents list prints [{"type","content"}, …];
    • incidents get prints {"number","content"};
    • resources prints {"sections","content"}.
  • Any other response is an error, never an empty result: "unexpected incidents response", "unexpected incident response" or "unexpected resources response". That covers null, {}, a missing key or field, a listing without a type, and the old structured shapes.
  • The skill's incidents get example now passes the number as an argument, as the command takes it.
  • The server is unchanged, so this works with the flux-test and production servers that are deployed now. No release order is needed.

All commits are fix:. Merging into master makes tag.yml tag and release v0.6.1 (a patch release).

Tests and verification

  • api: TestListIncidents, TestListIncidentsUnexpectedShape, TestGetIncident, TestGetAppSignalResources and TestAppSignalUnexpectedShapes (success and error cases).
  • cmd: TestAppSignalIncidentsList and TestAppSignalIncidentsGetAndResources (text and --json).
  • All tests use response shapes captured from eyra-flux-test on 2026-10-27. Run against master, the cmd tests fail: list with the decode error above, and get and resources with empty output.
  • go test -race ./..., go vet ./... and go mod tidy -diff pass.
  • A local build from this branch works against both environments:
    • flux-test (--app Flux/prod): incidents list (all, --type anomaly, --json), incidents get 121 and resources (--sections namespaces, --json).
    • production (--project next --app Next/next.eyra.co): incidents list, incidents get 1 and resources.

Not in this PR: the server's appsignal apps list keeps AppSignal's header and URL lines (Flux issue 10448845294).

Pre-reviewed by an AI agent (herdr-projects flux · t-0083, head 8a58d3b): fixed M1 (an unknown, null or missing incidents shape fails with ErrUnexpectedIncidents instead of printing "No incidents found") and L1 (error-case tests); the incidents get and resources delta had no findings.

🤖 Generated with Claude Code

Written by an AI agent (Claude Code · claude-opus-5-5, herdr-projects flux · t-0079).

The server has sent each incident type's listing as AppSignal's own
Markdown ({"type","content"}) since the endpoint was added, either alone
for --type exception/anomaly or one per type under "exceptions" and
"anomalies". The CLI expected a list of structured incidents and failed
to decode every response. It now decodes both shapes and prints the
listings (exceptions first); --json gives [{"type","content"}, ...].

Flux issue: https://app.basecamp.com/5734045/buckets/45557517/todos/10448800497

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mellelieuwes and others added 2 commits October 27, 2026 19:58
A null, empty, missing or otherwise unknown "incidents" value, or a
listing without a type, decoded to zero listings, so the CLI printed
"No incidents found." (or [] with --json): a false all-clear. These now
fail with "unexpected incidents response".

Flux issue: https://app.basecamp.com/5734045/buckets/45557517/todos/10448800497

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ponses

Like incidents list, both commands expected structured fields the server
never sent. The server answers {"number","content"} for an incident and
{"sections","content"} for resources, with AppSignal's own Markdown as
content, so get printed an empty header and resources printed nothing.
Both now print that Markdown and give the server's object with --json.
A response without those fields fails with "unexpected incident
response" or "unexpected resources response". The skill's incidents get
example now passes the number as an argument, as the command takes it.

Flux issue: https://app.basecamp.com/5734045/buckets/45557517/todos/10448800497

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mellelieuwes mellelieuwes changed the title fix: flux appsignal incidents list reads the server's incident listings fix: flux appsignal incidents list, get and resources read the server's responses Oct 27, 2026

@JoeriDijkstra JoeriDijkstra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mellelieuwes
mellelieuwes merged commit a254b33 into master Oct 28, 2026
2 checks passed
@mellelieuwes
mellelieuwes deleted the hp/flux/t-0079-incidents-list-decode branch October 28, 2026 07:53
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.

2 participants