Repository navigation
io.sh: topics list --limit without jq is a usage error (exit 2), not an ignored flag - #37
Merged
Merged
Conversation
…d flag Without jq, io.sh topics list --limit N printed every suggestion and exited 0. Slicing the suggested array needs a JSON parser, so the flag now fails before the request with the needs-jq usage error (exit 2), as digest --limit already does.
Contributor
Author
|
Review by Grok Bot (Indian Opinion QA agent) Tested at head Fixes: no issue (as the PR says). Without jq, What I ran
Review
Automated checks (this head vs current main)
I'm Grok Bot, the automated QA agent for Indian Opinion. This is a comment-only review. I don't approve, request changes or merge. Local stack: PHP 8.4.28, Composer 2.11.3, MariaDB 11.8.9, Node 24.22.1, WordPress 7.1.5. |
makriman
marked this pull request as ready for review
December 5, 2026 20:30
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.
No issue is filed for this.
Problem
io.sh topics list --limit Nignores the limit when jq is not installed. It prints every suggestion and exits 0, so a script that asked for one suggestion gets all of them with no sign that the flag did nothing. The CLI andio.shwith jq both cutsuggestedto N.How to reproduce on
main(abeaadb)Hide jq from PATH (a directory of links to bash, curl and the other tools, without jq) and run against the REST stub in
test/stub-rest.mjs, which returns two suggestions:--limitneeds jq.suggestedhas 2 entries, nothing on stderr.--limit abcis also accepted silently, because the validator only runs when jq is present.With jq on PATH the same command gives one suggestion. Open PR #31 has the same behaviour without jq (it validates
--limitbut still skips the cut).Root cause
The
topics listbranch only applied the limit insideif [ "$HAVE_JQ" = 1 ], with noelse.digest --limitandbreaking recent --limitcallneedjqfor this case;topics listdid not.The change
A correct limit without jq is not feasible in POSIX shell:
suggestedis a JSON array of objects whose string fields may hold commas, brackets and escaped quotes, so cutting it needs a JSON parser. So the flag fails clearly instead, exactly asdigest --limitdoes:io.sh topics list --limit Nwithout jq exits 2 withtopics list --limit needs jq (...)before any request. Without--limit,topics liststill prints the API's JSON unchanged, as documented. With jq nothing changes.The header comment of
io.shand the README sentence that lists the flags that need jq now nametopics list --limit. CHANGELOG line under Unreleased. No version bump.Tests
New
test/topics-limit-no-jq.test.mjs(node:test, local stub, no network). It builds a PATH without jq (links to every other command) and checks:--limit 1,100andabcexit 2 with the needs-jq message, print nothing on stdout and make no request to the stub;IO_SH_NO_JQ=1gives the same;topics listwithout--limitand without jq still prints the API JSON; with jq,io.shand the CLI return the samesuggested.node --test test/topics-limit-no-jq.test.mjswithio.shfrommain: 2 of 5 fail (the two no-jq--limitcases). With the fix: 5 of 5 pass.npm test: 37 tests, 36 pass, 1 skipped (the MCP bridge test, which needs../mcp), 0 fail. Node 22, jq 1.7.bash -n io.sh: clean. shellcheck and bats are not run here.Conflicts with open PRs
fix/28-io-sh-usage-exit) rewrites the sametopics listline (limit_ofsetsLIMITinstead of printing). Resolution: keep io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31's line and add this PR's guard first, so it readsallow 'topics list' 0 limit; if [ -n "$(f limit)" ]; then needjq 'topics list --limit'; fi; limit_of 10; call GET /agent/topics '' authand keep io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31's jq branch using
$LIMIT. io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31's bats suite could take a matching case once both land.## [Unreleased]block toCHANGELOG.md: a one-line merge.Owner decision
Making
--limitfail without jq is the choice that leaves every working call as it was:topics listwith no--limitstill works without jq. The alternative is to accept--limitwithout jq and print a warning on stderr while returning the full list; that keeps exit 0 for scripts that pass--limittoday, but a script that relies on the cut still gets the wrong answer. This PR follows the existingdigest --limitrule instead.