jackwener/OpenCLI · error · ArgumentError
unknown feed tab "${tab}"
Error message
unknown feed tab "${tab}" What it means
buildFeedUrl maps a validated tab key to its path via FEED_TABS and throws ArgumentError for unknown keys. Unlike requireFeedTab, this is a low-level guard for callers that bypass option validation, so an unknown tab reaching here indicates the tab was never normalized/validated upstream.
Source
Thrown at clis/upwork/utils.js:121
/**
* Build the Upwork search URL. Only forwards filters the user actually
* supplied so the URL stays canonical and round-trippable.
*/
export function buildSearchUrl({ query, location, category, sort, page, perPage }) {
const params = new URLSearchParams();
params.set('q', query);
if (location) params.set('location', location);
if (category) params.set('category2_uid', category);
if (sort && sort !== 'recency') params.set('sort', sort);
if (perPage && perPage !== 10) params.set('per_page', String(perPage));
if (page && page > 1) params.set('page', String(page));
return `${UPWORK_ORIGIN}/nx/search/jobs/?${params.toString()}`;
}
export function buildFeedUrl(tab) {
const t = FEED_TABS[tab];
if (!t) throw new ArgumentError(`unknown feed tab "${tab}"`);
return `${UPWORK_ORIGIN}${t.path}`;
}
export function feedStateKey(tab) {
const t = FEED_TABS[tab];
if (!t) throw new ArgumentError(`unknown feed tab "${tab}"`);
return t.state;
}
export function buildJobUrl(ciphertext) {
return `${UPWORK_ORIGIN}/jobs/${ciphertext}`;
}
export function isValidCiphertext(value) {
return CIPHERTEXT_PATTERN.test(String(value ?? '').trim());
}
/**View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the tab through requireFeedTab() before calling buildFeedUrl
- Use only 'best-matches' or 'most-recent'
- Upgrade the package if you expect a newer tab to exist — this version may not support it
Example fix
// before buildFeedUrl(userTab); // throws for unknown tab // after buildFeedUrl(requireFeedTab(userTab));
Defensive patterns
Strategy: validation
Validate before calling
function safeBuildFeedUrl(tab) {
const valid = ['best-matches', 'most-recent'];
if (!valid.includes(tab)) return null;
return buildFeedUrl(tab);
} Type guard
function isKnownTab(v) {
return typeof v === 'string' && ['best-matches','most-recent'].includes(v);
} Try / catch
try {
return buildFeedUrl(tab);
} catch (e) {
if (e instanceof ArgumentError && /unknown feed tab/.test(e.message)) {
return buildFeedUrl('best-matches');
}
throw e;
} Prevention
- Run user/config input through requireFeedTab before internal helpers
- Validate config values at load time
- Pin the package version and match scripts to its tab set
When it happens
Trigger: Calling buildFeedUrl directly with a raw/unvalidated string, or with a tab value that was lowercased differently or comes from a config file without passing through requireFeedTab first.
Common situations: Custom scripts importing the internal helper with user input; config-driven tabs not validated at load time; new tab keys assumed to exist but not present in FEED_TABS in this version.
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
- upwork tab must be one of ${Object.keys(FEED_TABS).join(' /
- upwork sort must be one of ${Array.from(SORT_VALUES).join('
- ${label} must be one of: ${Object.keys(choices).join(', ')}
- ${label} must be one of: ${choices.join(', ')}
- rest-countries region "${value}" is not recognised
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5a9ded88caf4ae9a.
Report an issue: GitHub.