Repository navigation
briefs: refuse --until not later than --since (exit 6) in the CLI and io.sh - #38
Merged
Merged
Conversation
…e CLI and io.sh An inverted or empty window was sent to the API and answered as an empty page with exit 0, which reads like no news matched. Both entry points now compare the two times as instants after the cursor is read and stop before any request with invalid_field and a message that names both values, as the MCP server's search_briefs does (IndianOpinion/mcp#20). io.sh does the comparison in bash arithmetic, so it needs neither jq nor a particular date(1).
Contributor
Author
|
Review by Grok Bot (Indian Opinion QA agent) Tested at head Fixes: Refs IndianOpinion/mcp#20 (CLI side). What I ran
ReviewNothing blocking. One error for an impossible window in the REST route, the MCP server and the CLI is the right outcome. 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:31
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.
Refs IndianOpinion/mcp#20
That issue reported that an inverted
since/untilwindow comes back as an ordinary empty result in three places: the REST route, the MCP server and the CLI. IndianOpinion/mcp#34 fixes the MCP side. This PR is the CLI side, for both entry points (bin/indianopinion.mjsandio.sh). The REST route is not in this repository and stays out of scope, so this refers to the issue rather than closing it.How to reproduce on
main(abeaadb)Against the REST stub in
test/stub-rest.mjs(both the paging and the older non-paging form):search_briefsgives after mcp#34.{"ok":true,"count":0,"items":[],"next_cursor":null}, which reads like "no news matched". The CLI sends one or two requests for it (two on the non-paging route),io.shone. An equal pair (--since X --until X) behaves the same.Root cause
Both entry points validate each time on its own (
timeFlagin the CLI,isotimeinio.sh) but never compare the two.The change
After the cursor is read (as the MCP fix does it, after its cursor decode), both entry points compare
--sinceand--untilas instants. If--untilis not later than--since, they stop before any request with exit 6 (the exit code the CLI already uses for a bad time) and the same error in both:The wording follows the MCP message, with the flag names the CLI uses in its other time errors. The CLI also sets
field: "until", astimeFlagdoes for its own errors. An equal pair is refused too, as mcp#34 does: a window of zero length holds nothing (the CLI's own fallback filter keeps only items published before--until).checkWindow(since, until)next toisoTime, called once incmdBriefs.io.sh:isoinstantturns a time thatisotimeaccepts into seconds since 1970 (UTC) plus a nine-digit fraction, in plain bash arithmetic (days from the civil date, then the offset). It does not calldate(1), whose flags differ between GNU and BSD, and it does not need jq, so the check works in everyio.shsetup.windowdoes the comparison. Neither runs inside$(...), so the exit is not lost in a subshell (the trap io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31 fixes elsewhere).Tests
New
test/briefs-window.test.mjs(node:test, local stubs, no network, no live API). For the CLI andio.sh, on both stub forms, seven impossible windows: an earlieruntil, an equal pair,+05:30makinguntilearlier,+0530without a colon, date-only values (earlier and equal) and a fraction of a second. Each must exit 6, print nothing on stdout, give the exact message above and make no request.io.shis also checked withIO_SH_NO_JQ=1. Valid windows (including ones where the text order and the instant order differ, such as2026-11-10T05:30:00+05:30to2026-11-10T00:00:01Z) still reach the API, a malformed--sincekeeps its own message, and--sinceor--untilalone still work.main: 2 of 3 fail. With the fix: 3 of 3 pass.npm test: 35 tests, 34 pass, 1 skipped (the MCP bridge test, which needs../mcp), 0 fail. Node 22, jq 1.7.io.sh'sisoinstantwas checked against the CLI'sisoTimefor 312 values (fixed edge cases such as leap days, 0001-01-01, 9999-12-31,+14:00and-12:00, plus 300 random date-times with offsets): 0 mismatches. That harness is not committed.bash -n io.sh: clean. shellcheck and bats are not run here.Conflicts with open PRs
## [Unreleased]block toCHANGELOG.md: keep both lines.cmdBriefsand theio.shbriefs branch, and io.sh: a usage error from --limit or an on/off flag stops before the request (exit 2) #31 changes the--limitline just above.git merge-treeshows both merge cleanly with this branch apart fromCHANGELOG.md. After briefs --category: an empty answer for an unknown category says so (warning, categories_seen) #34, the window check still runs before its category hint, so an impossible window never triggers the extra sample request.