feat(incident): resolve 6-char short ids in detail/get + add list --nums#26
Merged
Conversation
`incident detail <id>` and `incident get <id>` assumed a full 24-char
ObjectID and sent the positional arg straight into ObjectID-typed fields,
so a 6-char short id (the "num" shown in the UI, e.g. 311510) failed with
HTTP 400. The only backend path that accepts a num is /incident/list,
which the agent previously reached only by luck and a wide-enough --since.
Detect a 6-hex arg and resolve it to a full id via /incident/list with
`nums` over the last 30 days (the list API caps its query span at ~30 days):
- unique hit -> proceed with the resolved full id
- multiple -> surface the candidates (num is non-unique by design) and
stop; never silently analyze the wrong incident
- none -> clear error pointing at the full-id fallback
A 24-char id (or any non-short value) passes through unchanged.
Also add `incident list --nums` for explicit short-id filtering.
ysyneu
added a commit
that referenced
this pull request
Jun 2, 2026
Reconcile the full-OpenAPI-coverage feature with main's #26 (incident 6-char short-id resolution in detail/get + list --nums) and #27 (shell tab-completion + install.sh auto-setup). incident.go conflicts resolved to main's design: - list: keep --nums (#26) plus the eval's "--since→--until window < 31d" help text. - get: adopt #26's resolveIncidentArg→List-by-incident_ids body; the full-coverage branch's /incident/info get is superseded by #26's new `detail` command (which carries the no-window Info path). All 7 incident short-id tests pass. postmortem.go / status_page.go (deleted by the coverage branch in favor of generated commands) kept deleted; #27's registerEnumFlag additions to them drop with the files — generated post-mortem/status-page commands cover those ops. completion.go + install.sh + the curated commands' registerEnumFlag calls retained.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A user asked the AI-SRE agent to "分析故障 311510".
311510is an incident short id (thenumshown in the UI — the trailing 6 hex of the 24-char Mongo ObjectID6a12a4502f0a2396b3311510). The agent failed repeatedly:incident detail 311510cannot unmarshal into an ObjectID, length must be 24 but it is 6incident get 311510incident_idsincident list --query 311510--since 24h; incident was ~8 days old)The backend does support short-id lookup — but only on
POST /incident/listvia thenumsparam (and a 6-charqueryauto-promotion). The single-incident verbs (detail/get) route the arg into ObjectID-typed fields, so a short id can never work there; and the one path that resolves it was hidden behind a narrow default time window.The short id is non-unique by design (
numis the ObjectID's trailing 3 bytes — backend field is commented "短标识,可能重复"), so it can't be soundly mapped onto the single-result/incident/infoendpoint. Resolution therefore belongs in the CLI consumer layer (go-flashduty stays 1:1 with the API;/incident/infokeeps its unambiguous contract).What
incident detail <id>/incident get <id>: detect a 6-hex arg and resolve it to a full id via/incident/listwithnumsover the last 30 days (the list API caps its span at ~31 days):incident list --numsfor explicit short-id filteringVerification
go build ./...,go vet ./..., fullgo test ./...— green;gofmtclean.incident_short_id_test.go) assert the exact wire payloads against the go-flashduty stub:nums:[…]+ a 30-day span →/incident/list, then the resolved full id →/incident/info; ambiguity → candidate list with no/incident/infocall; not-found → descriptive error; full id → passthrough with no resolve;--nums→ array on the wire.since=14dquery returned exactly6a12a4502f0a2396b3311510)./incident/list, so I couldn't exercise the real endpoint with valid creds. The composed behavior is covered by the unit tests + the transcript evidence above.Notes
numson the MCPquery_incidentstool and add a one-line short-id note to the flashduty skill.make lintcurrently fails on a pre-existing toolchain skew (go.modgo 1.25.1vs golangci-lint built against go1.24), unrelated to this change.