{"record":{"id":"63be0e97bddfe986","repo":"heygen-com/hyperframes","slug":"errorprefix-must-be-allowed-join-got-63be0e","errorCode":null,"errorMessage":"${errorPrefix} must be ${allowed.join(\"|\")}; got ${s}","messagePattern":"(.+?) must be (.+?); got (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/lambda.ts","lineNumber":464,"sourceCode":"  return n;\n}\n\n/**\n * Parse a string-union flag against a closed set of allowed values.\n * Returns `defaultValue` (which may be `undefined`) when the input is\n * empty; throws with a flag-specific message when the value is set\n * but unrecognised.\n */\nfunction parseEnum<T extends string>(\n  raw: unknown,\n  allowed: readonly T[],\n  errorPrefix: string,\n  defaultValue: T | undefined,\n): T | undefined {\n  if (raw === undefined || raw === null || raw === \"\") return defaultValue;\n  const s = String(raw);\n  if ((allowed as readonly string[]).includes(s)) return s as T;\n  throw new Error(`${errorPrefix} must be ${allowed.join(\"|\")}; got ${s}`);\n}\n\nconst FORMATS = [\n  \"mp4\",\n  \"mov\",\n  \"png-sequence\",\n  \"webm\",\n] as const satisfies readonly DistributedFormat[];\nconst CODECS = [\"h264\", \"h265\"] as const;\nconst QUALITIES = [\"draft\", \"standard\", \"high\"] as const;\nconst CHROME_SOURCES = [\"sparticuz\", \"chrome-headless-shell\"] as const;\n\nconst parseFormat = (raw: unknown): (typeof FORMATS)[number] =>\n  parseEnum(raw, FORMATS, \"[lambda render] --format\", \"mp4\")!;\nconst parseCodec = (raw: unknown): (typeof CODECS)[number] | undefined =>\n  parseEnum(raw, CODECS, \"[lambda render] --codec\", undefined);\nconst parseQuality = (raw: unknown): (typeof QUALITIES)[number] | undefined =>\n  parseEnum(raw, QUALITIES, \"[lambda render] --quality\", undefined);","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/cli/src/commands/lambda.ts#L446-L482","documentation":"Thrown by parseEnum when a string-union flag was supplied with a value not in the allowed set. parseEnum is the closed-set validator behind --format, --codec, --quality, and --chrome-source; the error interpolates the errorPrefix (which flag), the full allowed list, and the offending value, so the correct choices are visible in the message.","triggerScenarios":"Passing `--format avi` (not in mp4|mov|png-sequence|webm); `--codec av1`; `--quality ultra`; `--chrome-source puppeteer`; or any typo of an accepted value for these four flags on `hyperframes lambda render` / `lambda render-batch` / `lambda deploy`.","commonSituations":"Typos (`mp5` instead of `mp4`); casing (`H264` vs `h264` — values are case-sensitive); assuming an unsupported option exists; version drift where a value was removed.","solutions":["Use one of the values listed in the error message exactly (case-sensitive).","Omit the flag to accept its default (e.g. mp4 for format, sparticuz for chrome-source).","Check the CLI help (`hyperframes lambda render -h`) for the current accepted values for your HyperFrames version."],"exampleFix":"# before\nhyperframes lambda render ./proj --width 1920 --height 1080 --format avi\n# after\nhyperframes lambda render ./proj --width 1920 --height 1080 --format mp4","handlingStrategy":"validation","validationCode":"// Validate enum flags against the allowed sets before invoking lambda\nconst FORMATS = [\"mp4\", \"mov\", \"png-sequence\", \"webm\"] as const;\nconst CODECS = [\"h264\", \"h265\"] as const;\nfunction assertEnum<T extends string>(v: string, allowed: readonly T[], name: string): T {\n  if (!allowed.includes(v as T)) throw new Error(`${name} must be one of ${allowed.join(\"|\")}`);\n  return v as T;\n}","typeGuard":"function isOneOf<T extends string>(v: string, allowed: readonly T[]): v is T {\n  return (allowed as readonly string[]).includes(v);\n}","tryCatchPattern":"try {\n  // run lambda render\n} catch (err) {\n  if (/must be .+; got/.test((err as Error).message))) {\n    // message lists valid values; pick one and re-run\n  }\n}","preventionTips":["Pin to the values listed in `hyperframes lambda render -h`.","Lowercase enum values (h264, not H264).","Build flag values from a typed constant array rather than free strings."],"tags":["cli","input-validation","lambda","enum","args"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}