{"record":{"id":"46c99660d6e34575","repo":"jackwener/OpenCLI","slug":"homebrew-label-value-is-not-supported","errorCode":null,"errorMessage":"homebrew ${label} \"${value}\" is not supported","messagePattern":"homebrew (.+?) \"(.+?)\" is not supported","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/homebrew/utils.js","lineNumber":52,"sourceCode":"export function requireToken(value, label) {\n    const s = String(value ?? '').trim();\n    if (!s) {\n        throw new ArgumentError(`homebrew ${label} is required (e.g. \"wget\", \"gcc@13\", \"firefox\")`);\n    }\n    if (s.length > 100 || !TOKEN.test(s)) {\n        throw new ArgumentError(\n            `homebrew ${label} \"${value}\" is not a valid token`,\n            'Use letters / digits / \"_-.+@\", starting with a letter or digit (max 100 chars).',\n        );\n    }\n    return s;\n}\n\nexport function requireOneOf(value, allowed, label) {\n    const s = String(value ?? '').trim().toLowerCase();\n    if (!s) throw new ArgumentError(`homebrew ${label} is required`);\n    if (!allowed.includes(s)) {\n        throw new ArgumentError(\n            `homebrew ${label} \"${value}\" is not supported`,\n            `Allowed: ${allowed.join(', ')}.`,\n        );\n    }\n    return s;\n}\n\nexport async function brewFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that formulae.brew.sh is reachable from this network.',\n        );\n    }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/homebrew/utils.js#L34-L70","documentation":"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.","triggerScenarios":"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').","commonSituations":"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.","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."],"exampleFix":"// before\nawait type('formulas');        // not in allowed list\n// after\nawait type('formula');         // allowed value","handlingStrategy":"validation","validationCode":"function validateOneOf(value, allowed, label) {\n  const s = String(value ?? '').trim().toLowerCase();\n  if (!allowed.includes(s)) {\n    throw new Error(`${label} \"${value}\" not supported; allowed: ${allowed.join(', ')}`);\n  }\n  return s;\n}\nvalidateOneOf(userInput, ['formula', 'cask'], 'type');","typeGuard":"function isAllowed(v, allowed) {\n  return typeof v === 'string' && allowed.includes(v.trim().toLowerCase());\n}","tryCatchPattern":"try {\n  await run({ type: userInput });\n} catch (err) {\n  if (err instanceof ArgumentError && /not supported/.test(err.message)) {\n    console.error(err.message, err.hint ?? ''); // hint lists allowed values\n  } else throw err;\n}","preventionTips":["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."],"tags":["argument-validation","invalid-argument","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}