jackwener/OpenCLI · error · ArgumentError
indeed sort must be "relevance" or "date", got "${value}"
Error message
indeed sort must be "relevance" or "date", got "${value}" What it means
requireSort validates the sort option against the allowed set {relevance, date} (case-insensitive, trimmed). Anything else raises an ArgumentError echoing the bad value. This mirrors Indeed's search sort parameter.
Source
Thrown at clis/indeed/utils.js:86
throw new ArgumentError(`indeed ${label} cannot be empty`);
}
return q;
}
/** "1" / "3" / "7" / "14" — accepted by Indeed's `fromage` filter. */
export function requireFromage(value) {
if (value === undefined || value === null || value === '') return '';
const v = String(value).trim();
if (!FROMAGE_VALUES.has(v)) {
throw new ArgumentError(`indeed fromage must be one of 1/3/7/14 (days), got "${value}"`);
}
return v;
}
export function requireSort(value, defaultValue = 'relevance') {
const v = String(value ?? defaultValue).trim().toLowerCase();
if (!SORT_VALUES.has(v)) {
throw new ArgumentError(`indeed sort must be "relevance" or "date", got "${value}"`);
}
return v;
}
/**
* Build an Indeed search URL with only the user-supplied filters set.
* Indeed treats absent params as defaults; we never pass empty strings
* because the page will echo them back into the query and the URL
* stays cleaner for round-tripping.
*/
export function buildSearchUrl({ query, location, fromage, sort, start }) {
const params = new URLSearchParams();
params.set('q', query);
if (location) params.set('l', location);
if (fromage) params.set('fromage', fromage);
if (sort && sort !== 'relevance') params.set('sort', sort);
if (start && start > 0) params.set('start', String(start));
return `${INDEED_ORIGIN}/jobs?${params.toString()}`;View on GitHub (pinned to 49907e53dc)
Solutions
- Use sort date for newest-first or sort relevance (the default).
- Omit the flag to get the default relevance ordering.
- Check spelling/case — it is lowercased before the check, so only the word itself matters.
Example fix
// before indeed sort newest // after indeed sort date
Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED = new Set(['1','3','7','14']); if (fromage != null && fromage !== '' && !ALLOWED.has(String(fromage).trim())) fromage = '14';
Type guard
function isFromage(v) { return v == null || v === '' || ['1','3','7','14'].includes(String(v).trim()); } Try / catch
try { run(['search', '--fromage', fromage]); } catch (e) { if (e instanceof ArgumentError && e.message.includes('fromage')) { console.warn(`Unsupported fromage "${fromage}"; omitting filter`); return run(['search']); } throw e; } Prevention
- Restrict UIs/configs to a dropdown of 1/3/7/14.
- Map arbitrary day ranges to the nearest supported value.
- Never append time units to the value.
When it happens
Trigger: `indeed sort newest`, `sort datetime`, `sort posted_date`, or localized words like 'fecha' — values not in relevance/date.
Common situations: Copying flag values from other job APIs (e.g. 'newest' from other boards); assuming full 'datePosted' style names work; typos like 'relevence'.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- indeed fromage must be one of 1/3/7/14 (days), got "${value}
- zhihu search --type must be one of: ${TYPES.join(', ')}
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/71efd8ca301d6905.
Report an issue: GitHub.