jackwener/OpenCLI · error · CliError
INVALID_ARG
INVALID_ARG
Error message
--date is not supported for ${period} period What it means
A CliError with code INVALID_ARG thrown by the `hf top` (papers) command when --date is passed together with --period weekly or monthly. The Hugging Face papers API only supports a date parameter for the daily period, so the CLI rejects the invalid combination up front.
Source
Thrown at clis/hf/top.js:61
{ name: 'period', type: 'str', default: 'daily', choices: ['daily', 'weekly', 'monthly'], help: 'Time period: daily, weekly, or monthly' },
],
columns: ['rank', 'id', 'title', 'upvotes', 'authors'],
footerExtra: (kwargs) => {
if (kwargs._footerDate)
return kwargs._footerDate;
if (kwargs.period === 'monthly')
return getMonthRange();
if (kwargs.period === 'weekly')
return getWeekRange();
return kwargs.date ?? new Date().toISOString().slice(0, 10);
},
func: async (kwargs) => {
const period = String(kwargs.period ?? 'daily');
const all = Boolean(kwargs.all);
const endpoint = process.env.HF_ENDPOINT?.replace(/\/+$/, '') || 'https://huggingface.co';
if (period === 'weekly' || period === 'monthly') {
if (kwargs.date) {
throw new CliError('INVALID_ARG', `--date is not supported for ${period} period`, `Omit --date when using --period ${period}`);
}
const url = `${endpoint}/api/papers?period=${period}`;
const res = await fetch(url);
if (!res.ok)
throw new CliError('FETCH_ERROR', `HF API error: ${res.status} ${res.statusText}`, 'Check HF_ENDPOINT or try again later');
const body = await res.json();
if (!Array.isArray(body))
throw new CliError('FETCH_ERROR', 'Unexpected HF API response', 'Check endpoint');
const data = body;
const dates = data.map((d) => d.publishedAt).filter(Boolean).sort();
if (dates.length > 0) {
if (period === 'monthly') {
const d = new Date(dates[0]);
kwargs._footerDate = `${MONTH_ABBR[d.getUTCMonth()]} ${d.getUTCFullYear()}`;
}
else {
const start = new Date(dates[0]);
const end = new Date(dates[dates.length - 1]);View on GitHub (pinned to 49907e53dc)
Solutions
- Drop --date and re-run: `hf top --period weekly`
- Use the default daily period when a specific date is needed: `hf top --date 2024-01-15`
- Update scripts to only pass --date when period is daily/omitted
Example fix
// before await run(['hf', 'top', '--period', 'weekly', '--date', '2024-01-15']); // after await run(['hf', 'top', '--period', 'weekly']);
Defensive patterns
Strategy: validation
Validate before calling
// validate flag combination before invoking
function validateHfTopArgs(args) {
const period = args.period ?? 'daily';
if (args.date && (period === 'weekly' || period === 'monthly')) {
throw new Error(`--date is not supported with --period ${period}; omit --date`);
}
} Try / catch
try {
await run(['hf', 'top', ...flags]);
} catch (e) {
if (String(e.message ?? e).includes('not supported for')) {
// drop --date and re-run with the period only
return await run(['hf', 'top', '--period', period]);
}
throw e;
} Prevention
- Remember --date applies only to the daily period
- Build CLI flags from a whitelist per period in scripts
- Lint CI configs for stray --date flags with weekly/monthly
- Read the command's --help before combining flags
When it happens
Trigger: Invoking the command like `hf top --period weekly --date 2024-01-15` or `hf top --period monthly --date ...`; any truthy kwargs.date while period is 'weekly' or 'monthly'.
Common situations: Users assuming weekly/monthly rankings can be back-dated like daily ones; scripts parameterizing both flags generically; copying the daily invocation and changing only the period.
Related errors
- hf models sort must be one of ${SORT_OPTIONS.join(', ')}
- hf models limit must be a positive integer
- hf models limit must be <= 100
- hf paper id cannot be empty
- hf paper id "${args.id}" is not a valid arXiv id
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b841d6860f39a15f.
Report an issue: GitHub.