GeezerVison is showing github.com — fix(opencode-usage-export): validate --window-hours/--fresh-hours (#4739) by developing-today[bot] · Pull Request #6810 · developing-today/code
Conversation
developing-today
Bot
commented
Nov 7, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #4739.
opencode-usage-export parsed --window-hours / --fresh-hours with a bare Number(...) and never checked the result: --window-hours banana published a zero-filled status: "ok" document (breaking the module's fail-closed contract), --window-hours Infinity included every session, and --fresh-hours banana exited store-stale with a misleading "the live store may have moved" diagnosis for a healthy store.
Change
- New
parseHourFlag in opencode-usage-export.mjs: a missing, non-numeric, NaN, infinite, zero, or negative value throws ExportError("invalid-argument", exit 2) naming the flag — before any store read. The error carries the partially parsed args so the failure document still routes to --out-dir when one was given.
run() now routes argument errors through the same failure-document path as store errors instead of an uncaught throw (unknown flags get the same treatment).
- Valid positive finite values behave exactly as before; a success document can no longer carry a non-finite or non-positive
windowHours (it can only be built from a validated value or the defaults).
Tests
5 new cases in opencode-usage-export.test.mjs (junk window, missing window value, negative window, junk freshness — each asserting no ok document and a detail naming the bad argument — plus a valid-value control). Laptop run, node --test pm-stack/opencode-usage-export/opencode-usage-export.test.mjs: 9/9 pass (4 pre-existing + 5 new). The directory form (node --test pm-stack/opencode-usage-export/) fails identically on clean main — pre-existing, untouched by this PR. Full suite verification is CI's.
🤖 Queue worker lane F (fallback mode, queue backend down — code#6619).
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
)
A bare Number(...) with no check let a junk window publish a
zero-filled status:ok document (NaN window -> 0 sessions; Infinity ->
every session) and a junk freshness report a fresh store as moved
(store-stale). Both flags now go through parseHourFlag: missing,
non-numeric, NaN, infinite, zero, or negative values throw an
ExportError(invalid-argument, exit 2) naming the flag, before any
store read. run() routes argument errors to a failure document
(written to --out-dir when it was parsed) instead of an uncaught
throw. Valid positive finite values behave exactly as before.
Tests: 5 new cases in opencode-usage-export.test.mjs (junk window,
missing window value, negative window, junk freshness, valid-value
control) - 9/9 pass on the laptop, node --test file form. (The
directory form of node --test fails identically on clean main;
pre-existing, untouched.)
coderabbitai
Bot
commented
Nov 7, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Important
Review skipped
Bot user detected.
To trigger a single review, invoke the @coderabbitai review command.
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
f42ab9cb-f2c0-4319-8945-69912b2a6672
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Cross-link from #6934 (filed this run): the residual --db/--out-dir door of #4739 that this PR does not cover — trailing/empty --db silently exports the default store, trailing --out-dir silently writes the default out dir, verified on current main (def55caf48, probe on the laptop). #6934 is queued as a small-fix to land after (or folded into) this PR; its acceptance criteria include not regressing this PR's parse-error failure-document restructure.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
# Conflicts:
# pm-stack/opencode-usage-export/opencode-usage-export.test.mjs
Uh oh!
There was an error while loading. Please reload this page.
|
🤖 Agent note · pairwise salvage comparison (task 14162) — nothing unique in PR #4790 or PR #6107
- Agent: repo queue worker, lane code-h (repo-worker-code)
- Canonical: this PR (fix(opencode-usage-export): validate --window-hours/--fresh-hours (#4739) #6810, commit 761c60f) landed the opencode-usage-export: --window-hours / --fresh-hours are never validated — a junk window publishes a zero-filled status:ok document, a junk freshness reports a fresh store as moved #4739 fix on main:
parseHourFlag rejects missing, non-numeric/NaN, infinite, zero, and negative hour values as a positive-finite check, and the error carries the partially parsed args so the failure document still routes to the selected --out-dir (line: err?.args?.outDir).
- PR fix(usage-export): validate hours flags (#4739) #4790 diffed against canonical: its four tests (invalid --window-hours / --fresh-hours fail closed with exit 2 naming the flag; rejection before any store read; valid values retain behavior) map one-to-one onto behaviors + tests on main (junk/missing/negative window, junk fresh diagnosed invalid-argument not store-stale, valid positive behave as before). Its one distinctive behavior — preserving the selected output directory on usage errors — is the canonical's
err.args mechanism above. Nothing unique.
- PR Fix #4739: validate usage exporter hour options #6107 diffed against canonical: its tests (per-option invalid value rejected before store read; missing value before the next option; positive-finite preserves behavior) are the same behaviors; a flag-shaped value is
Number("--fresh-hours") = NaN, rejected by the same canonical path the junk-value tests cover. Nothing unique.
- Evidence: targeted suite on current main —
node --test pm-stack/opencode-usage-export/opencode-usage-export.test.mjs → 12 pass, 0 fail. Issue opencode-usage-export: --window-hours / --fresh-hours are never validated — a junk window publishes a zero-filled status:ok document, a junk freshness reports a fresh store as moved #4739 is CLOSED (completed, 2026-11-08). Both duplicates are CONFLICTING with main and are being closed as superseded by task 14162; no branches deleted.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 9, 2026
Reviewers
dezren39
Awaiting requested review from dezren39
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
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.
|