Skip to content

fix(monit-query): diagnose never accepted mysql — drop it from flag and card - #157

Merged
ysyneu merged 3 commits into
mainfrom
fix/monit-query-diagnose-dstype
Aug 20, 2026
Merged

fix(monit-query): diagnose never accepted mysql — drop it from flag and card#157
ysyneu merged 3 commits into
mainfrom
fix/monit-query-diagnose-dstype

Conversation

@ysyneu

@ysyneu ysyneu commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

What was wrong

monit-query diagnose advertised mysql as a valid --ds-type in three places:

where what it said
internal/cli/monit_query.go flag usage Datasource type: prometheus|victorialogs|loki|mysql (required)
internal/cli/monit_query.go registerEnumFlag "prometheus", "victorialogs", "loki", "mysql"
skills/flashduty/reference/monit-query.md gotchas "only accepts prometheus, victorialogs, loki, mysql"

None of it is true. diagnose has exactly two operations and each is bound to a datasource-type set:

  • log_patternsloki, victorialogs
  • metric_trendsprometheus

With no third operation, --ds-type mysql cannot succeed under any pairing — the server returns an invalid-parameter error every time.

registerEnumFlag only supplies shell completion; it does not validate. So mysql was never caught locally: it was suggested by tab-completion, documented in the card, sent to the server, and rejected there. A user or agent following either source hit a guaranteed failure.

Change

All three corrected. The card now states the pairing rather than a flat list, so the operation↔type relationship the server enforces is visible where the call is written, and the "why" survives the next edit:

log_patterns takes loki or victorialogs; metric_trends takes prometheus. There is no third operation, so no other --ds-type value can succeed — mysql, oracle, postgres, clickhouse, elasticsearch, and sls all come back as an invalid-parameter error however you pair them. monit datasource-list returns those types because data supports them; diagnose does not.

Verification

  • go build ./... clean
  • go run ./internal/cmd/skilldoc checkskilldoc: cards OK (the flag usage string is not part of this group's generated fence, so no regeneration was needed)
  • go test ./... → 9 packages ok, 0 failures

No test pinned the enum before this change, and none is added: the authoritative contract lives server-side, so a local list assertion would only restate the constant it guards.


Second commit: unblocking CI

The first push came back with lint red — not on this change, but a panic inside golangci-lint's package loader:

panic: file requires newer Go version go1.27 (application built with go1.26)

lint.yml asked for go-version: stable, and setup-go logged stable version resolved as 1.27.0. golangci-lint ships as a prebuilt binary that can only parse source up to the Go it was built with, so the moment Go 1.27.0 became stable, v2.11 started panicking. That makes lint red on every open PR with nothing in the repo having changed.

ci.yml already resolves Go via go-version-file: "go.mod". lint.yml now does the same, so the linter's toolchain moves when the module moves and an upstream Go release cannot break the gate on its own.

It rides along here rather than in its own PR because this PR could not be shown green without it. Reviewable independently: it is one commit touching one file.

CI after the fix: 12/12 green.

ysyneu added 3 commits August 19, 2026 20:35
…nd card

`diagnose` pairs one operation with one set of datasource types: `log_patterns`
takes `loki` or `victorialogs`, `metric_trends` takes `prometheus`. There is no
third operation, so no other `--ds-type` value can succeed; the server answers
with an invalid-parameter error for every other combination.

`--ds-type` advertised `mysql` in three places — the flag usage string, the
shell-completion enum, and the card's gotcha list. `registerEnumFlag` only feeds
completion, so `mysql` was never rejected locally: it travelled to the server and
failed there every time. Following either the card or the completion suggestion
produced a guaranteed error.

Correct all three, and state the operation/type pairing instead of a flat list so
the relationship the server actually enforces is visible at the call site.
golangci-lint is a prebuilt binary and can only parse source up to the Go
release it was built with. `go-version: stable` hands it whatever Go shipped
most recently, so Go 1.27.0 going stable made v2.11 (built with go1.26) panic
on load — "file requires newer Go version go1.27" — turning lint red on every
open PR without a single repo change.

ci.yml already resolves Go from go.mod. Do the same here so the linter's
toolchain moves when the module moves, and an upstream release cannot break
the gate on its own.
@ysyneu
ysyneu merged commit 384dd76 into main Aug 20, 2026
12 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