{"record":{"id":"29a5d4361be0218f","repo":"jackwener/OpenCLI","slug":"indeed-fromage-must-be-one-of-1-3-7-14-days-got","errorCode":null,"errorMessage":"indeed fromage must be one of 1/3/7/14 (days), got \"${value}\"","messagePattern":"indeed fromage must be one of 1/3/7/14 \\(days\\), got \"(.+?)\"","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/indeed/utils.js","lineNumber":78,"sourceCode":"        throw new ArgumentError(`indeed job id \"${value}\" is not a valid jk (expected 16-char lowercase hex)`);\n    }\n    return id;\n}\n\nexport function requireQuery(value, label = 'query') {\n    const q = String(value ?? '').trim();\n    if (!q) {\n        throw new ArgumentError(`indeed ${label} cannot be empty`);\n    }\n    return q;\n}\n\n/** \"1\" / \"3\" / \"7\" / \"14\" — accepted by Indeed's `fromage` filter. */\nexport function requireFromage(value) {\n    if (value === undefined || value === null || value === '') return '';\n    const v = String(value).trim();\n    if (!FROMAGE_VALUES.has(v)) {\n        throw new ArgumentError(`indeed fromage must be one of 1/3/7/14 (days), got \"${value}\"`);\n    }\n    return v;\n}\n\nexport function requireSort(value, defaultValue = 'relevance') {\n    const v = String(value ?? defaultValue).trim().toLowerCase();\n    if (!SORT_VALUES.has(v)) {\n        throw new ArgumentError(`indeed sort must be \"relevance\" or \"date\", got \"${value}\"`);\n    }\n    return v;\n}\n\n/**\n * Build an Indeed search URL with only the user-supplied filters set.\n * Indeed treats absent params as defaults; we never pass empty strings\n * because the page will echo them back into the query and the URL\n * stays cleaner for round-tripping.\n */","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/indeed/utils.js#L60-L96","documentation":"requireFromage restricts the date-posted filter to Indeed's accepted fromage values: exactly '1', '3', '7', or '14' (days). Any other value, including other numbers or unit-suffixed strings like '7d', throws an ArgumentError. Empty/undefined returns '' (filter omitted).","triggerScenarios":"`indeed fromage 30`, `fromage 7d`, `fromage last week`, or `fromage 24h` — any string not in {1,3,7,14}.","commonSituations":"Confusing this with other APIs' arbitrary day counts (e.g. 30 days); adding units; translating 'last 24 hours' into 1h instead of 1.","solutions":["Use one of the allowed values: 1, 3, 7, or 14.","Map desired ranges to the nearest supported value (e.g. 30 days → 14, the widest supported).","Omit the flag entirely for no date filter."],"exampleFix":"// before\nindeed fromage 30\n// after\nindeed fromage 14","handlingStrategy":"validation","validationCode":"const q = String(query ?? '').trim(); if (!q) throw new Error('query must be non-empty');","typeGuard":"function hasQuery(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try { run(['search', q]); } catch (e) { if (e instanceof ArgumentError && e.message.includes('cannot be empty')) { console.error('Search query is required'); process.exitCode = 2; } else throw e; }","preventionTips":["Require query env vars with ${QUERY:?}.","Trim and check inputs before invoking.","Fail fast in CI when config for search terms is missing."],"tags":["cli","enum-validation","argument-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}