Skip to content

Commit 36b908c

Browse files
committed
fix: reject victorialogs raw rows query missing start/end args
monit-query rows dispatched --ds-type victorialogs with --args victorialogs.type=raw straight to the backend without checking for victorialogs.start/victorialogs.end. The backend silently returns null (HTTP 200, exit 0) instead of an error, which caused an agent session to retry the same broken call ~10+ times before finding the doc that explains the raw-mode contract. Validate this known-bad combination client-side before dispatch, mirroring the existing required-flags check in the same RunE.
1 parent 45677ff commit 36b908c

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

internal/cli/monit_query.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ func newMonitQueryRowsCmd() *cobra.Command {
102102
if err != nil {
103103
return fmt.Errorf("invalid --args: %w", err)
104104
}
105+
if dsType == "victorialogs" && argsMap["victorialogs.type"] == "raw" &&
106+
(argsMap["victorialogs.start"] == "" || argsMap["victorialogs.end"] == "") {
107+
return fmt.Errorf("victorialogs raw mode requires --args victorialogs.start=<unix> --args victorialogs.end=<unix>; see skills/flashduty/reference/monit-query.md")
108+
}
105109

106110
return runCommand(cmd, args, func(ctx *RunContext) error {
107111
input := &flashduty.QueryRowsRequest{

internal/cli/monit_query_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,25 @@ func TestMonitQueryRowsInvalidArgs(t *testing.T) {
259259
t.Errorf("rows should not have been called: %d request(s)", stub.requests)
260260
}
261261
}
262+
263+
func TestMonitQueryRowsVictorialogsRawRequiresTimeRange(t *testing.T) {
264+
saveAndResetGlobals(t)
265+
stub := newGFStub(t)
266+
267+
_, err := execCommand(
268+
"monit-query", "rows",
269+
"--ds-type", "victorialogs",
270+
"--ds-name", "vl-prod",
271+
"--expr", "* | limit 2",
272+
"--args", "victorialogs.type=raw",
273+
)
274+
if err == nil {
275+
t.Fatal("expected error for victorialogs raw mode missing start/end, got nil")
276+
}
277+
if !strings.Contains(err.Error(), "victorialogs.start") || !strings.Contains(err.Error(), "victorialogs.end") {
278+
t.Errorf("expected error to mention victorialogs.start/end, got %q", err.Error())
279+
}
280+
if stub.requests != 0 {
281+
t.Errorf("rows should not have been called: %d request(s)", stub.requests)
282+
}
283+
}

0 commit comments

Comments
 (0)