jackwener/OpenCLI · error · ArgumentError
homebrew ${label} "${value}" is not supported
Error message
homebrew ${label} "${value}" is not supported What it means
requireOneOf validates an enum-like option against an explicit allow-list after trimming and lowercasing the input. When the value is non-empty but not a member of the allowed set, the library throws this ArgumentError with a hint listing the valid options. It exists to catch typos and unsupported values before an HTTP request is made.
Source
Thrown at clis/homebrew/utils.js:52
export function requireToken(value, label) {
const s = String(value ?? '').trim();
if (!s) {
throw new ArgumentError(`homebrew ${label} is required (e.g. "wget", "gcc@13", "firefox")`);
}
if (s.length > 100 || !TOKEN.test(s)) {
throw new ArgumentError(
`homebrew ${label} "${value}" is not a valid token`,
'Use letters / digits / "_-.+@", starting with a letter or digit (max 100 chars).',
);
}
return s;
}
export function requireOneOf(value, allowed, label) {
const s = String(value ?? '').trim().toLowerCase();
if (!s) throw new ArgumentError(`homebrew ${label} is required`);
if (!allowed.includes(s)) {
throw new ArgumentError(
`homebrew ${label} "${value}" is not supported`,
`Allowed: ${allowed.join(', ')}.`,
);
}
return s;
}
export async function brewFetch(url, label) {
let resp;
try {
resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
}
catch (err) {
throw new CommandExecutionError(
`${label} request failed: ${err?.message ?? err}`,
'Check that formulae.brew.sh is reachable from this network.',
);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Use exactly one of the allowed values listed in the error's hint (e.g. 'formula', 'cask', '30d', '90d').
- Trim and lowercase user input before passing it, since requireOneOf compares lowercased values.
- If a formerly valid value now fails, check for a library/API version change in the supported enum and update the caller or upgrade the library.
Example fix
// before
await type('formulas'); // not in allowed list
// after
await type('formula'); // allowed value Defensive patterns
Strategy: validation
Validate before calling
function validateOneOf(value, allowed, label) {
const s = String(value ?? '').trim().toLowerCase();
if (!allowed.includes(s)) {
throw new Error(`${label} "${value}" not supported; allowed: ${allowed.join(', ')}`);
}
return s;
}
validateOneOf(userInput, ['formula', 'cask'], 'type'); Type guard
function isAllowed(v, allowed) {
return typeof v === 'string' && allowed.includes(v.trim().toLowerCase());
} Try / catch
try {
await run({ type: userInput });
} catch (err) {
if (err instanceof ArgumentError && /not supported/.test(err.message)) {
console.error(err.message, err.hint ?? ''); // hint lists allowed values
} else throw err;
} Prevention
- Copy allowed values from the error hint or docs verbatim; don't pluralize or re-case them.
- Normalize user input (trim + lowercase) before calling.
- Centralize enum choices in a shared constant to avoid doc drift.
- After library upgrades, re-check that enum values haven't changed.
When it happens
Trigger: Calling type('formulas') when only 'formula' is allowed; window('all-time') when allowed windows are e.g. '30d','90d','365d'; passing a value with different casing that still isn't in the list, like type('CASKS').
Common situations: Typos or pluralizing an enum value; copying option names from an old version of the docs after the allowed set changed; passing a raw user string straight through without normalizing against the supported list.
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
- INVALID_ARGUMENT
- INVALID_ARGUMENT
- INVALID_ARGUMENT
- hf spaces sort must be one of ${SORT_OPTIONS.join(', ')}
- hf spaces limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/46c99660d6e34575.
Report an issue: GitHub.