Skip to content

fix: reject an invalid --jq filter before the command runs - #889

Merged
discostu105 merged 1 commit into
mainfrom
fix/815-validate-jq-early
Dec 4, 2026
Merged

discostu105 merged 1 commit into
mainfrom
fix/815-validate-jq-early

Conversation

@discostu105

Copy link
Copy Markdown
Member

An invalid --jq filter was only parsed when the result was printed, so a mutating command sent its request, changed the environment, and then exited 1 with invalid --jq filter. An agent reading that error would retry and create a duplicate.

validateGlobalFlags (root PersistentPreRunE, CLI and concurrent trees) now compiles the filter with output.CompileJQ and returns its error before the command body runs. The error is unchanged: validation_error, invalid --jq filter: ..., exit 1.

Tests: an httptest stub counting POSTs runs create scheduling-rule -f ... --agent --jq '.[' end to end and asserts zero requests plus the same envelope (fails on main); a valid filter still sends one request and filters the result.

Fixes #815

validateGlobalFlags now compiles the --jq filter, so a syntax error fails
before the command body sends a request. Previously a mutating command
(e.g. create scheduling-rule) made its change and only then exited 1
with invalid --jq filter, inviting a retry that created a duplicate.

Fixes #815
@discostu105
discostu105 requested a review from a team as a code owner December 4, 2026 18:19
@discostu105
discostu105 merged commit 68ccabd into main Dec 4, 2026
18 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.

An invalid --jq filter is reported only after a mutating command has made its change

1 participant