jackwener/OpenCLI · error · ArgumentError
Unknown --since "${sinceKey}". Valid: ${Object.keys(SINCE).j
Error message
Unknown --since "${sinceKey}". Valid: ${Object.keys(SINCE).join(', ')} What it means
The `opencli github-trending repos` command accepts a `--since` option that must be one of the keys in its SINCE map (daily/weekly/monthly). Any other value throws this ArgumentError listing the valid keys. It is an input-validation error thrown before any network request is made.
Source
Thrown at clis/github-trending/repos.js:117
cli({
site: 'github-trending',
name: 'repos',
access: 'read',
description: 'GitHub Trending repositories (public, no login). Filter by --language and --since.',
domain: 'github.com',
strategy: Strategy.PUBLIC,
browser: false,
args: [
{ name: 'since', type: 'string', default: 'daily', help: 'Time range: daily / weekly / monthly' },
{ name: 'language', type: 'string', default: '', help: 'Filter by programming language slug, e.g. python, rust, "c++"' },
{ name: 'limit', type: 'int', default: 25, help: 'Number of repositories to return (max 25)' },
],
columns: ['rank', 'repo', 'description', 'language', 'stars', 'forks', 'starsSince', 'url'],
func: async (args) => {
const sinceKey = String(args.since ?? 'daily').toLowerCase();
const since = SINCE[sinceKey];
if (!since) {
throw new ArgumentError(`Unknown --since "${sinceKey}". Valid: ${Object.keys(SINCE).join(', ')}`);
}
const n = Number(args.limit ?? 25);
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError('--limit must be a positive integer');
}
if (n > 25) {
throw new ArgumentError('--limit must be <= 25 (GitHub Trending lists at most 25 repositories)');
}
const limit = n;
const language = String(args.language ?? '').trim();
const path = language ? `/trending/${encodeURIComponent(language)}` : '/trending';
const url = new URL(`https://github.com${path}`);
url.searchParams.set('since', since);
let resp;
try {View on GitHub (pinned to 49907e53dc)
Solutions
- Use one of the listed valid values, typically: daily, weekly, monthly (lowercase)
- Run the command's help to see accepted --since values
- In scripts, validate/normalize the since value against ['daily','weekly','monthly'] before invoking
Example fix
// before opencli github-trending repos --since last-week // after opencli github-trending repos --since weekly
Defensive patterns
Strategy: validation
Validate before calling
const VALID_SINCE = ['daily', 'weekly', 'monthly'];
const since = String(rawSince ?? 'daily').toLowerCase();
if (!VALID_SINCE.includes(since)) throw new Error(`--since must be one of: ${VALID_SINCE.join(', ')}`); Type guard
function isArgumentError(e) { return e instanceof Error && e.name === 'ArgumentError'; } Try / catch
try {
await run(['opencli', 'github-trending', 'repos', '--since', since]);
} catch (e) {
if (e.name === 'ArgumentError') { console.error(e.message); process.exitCode = 2; }
else throw e;
} Prevention
- Whitelist --since values in wrapper scripts before invoking
- Always lowercase the value before passing it
- Read the command's --help to discover accepted values
When it happens
Trigger: Calling the command with `--since` set to a value not in SINCE — e.g. `--since day`, `--since Daily` handled only after lowercasing fails for other spellings like 'last-week', or an empty/garbage value.
Common situations: Guessing flag values instead of checking help output; scripting with a variable containing an unexpected default; typos like 'daiy' or 'week'; passing a date string ('2024-01-01') which the API does not support.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- tid must be a numeric thread id
- --from and --to must differ (got ${fromCity})
- --from and --to must differ (got ${fromCode})
- --from and --to must differ (got ${fromName})
- --limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a8e8689b1011beb8.
Report an issue: GitHub.