{"record":{"id":"e9e6f36029d7f490","repo":"remotion-dev/remotion","slug":"the-bitrate-quality-must-be-one-of-video-matting","errorCode":null,"errorMessage":"The bitrate quality must be one of ${VIDEO_MATTING_QUALITIES.join(', ')}.","messagePattern":"The bitrate quality must be one of (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/video-matting-quality.ts","lineNumber":27,"sourceCode":"] as const;\n\nexport type VideoMattingQuality = (typeof VIDEO_MATTING_QUALITIES)[number];\n\nexport type VideoMattingBitrate = number | VideoMattingQuality;\n\nexport const resolveVideoMattingQuality = (\n\tvalue: VideoMattingBitrate,\n): Quality => {\n\tif (typeof value === 'number') {\n\t\tif (!Number.isInteger(value) || value <= 0) {\n\t\t\tthrow new TypeError('A numeric bitrate must be a positive integer.');\n\t\t}\n\n\t\treturn new Quality({bitrate: value});\n\t}\n\n\tif (!VIDEO_MATTING_QUALITIES.includes(value)) {\n\t\tthrow new TypeError(\n\t\t\t`The bitrate quality must be one of ${VIDEO_MATTING_QUALITIES.join(', ')}.`,\n\t\t);\n\t}\n\n\treturn new Quality({quality: value, preferBitrate: true});\n};\n","sourceCodeStart":9,"sourceCodeEnd":34,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/video-matting-quality.ts#L9-L34","documentation":"When resolveVideoMattingQuality receives a string (a quality preset), it must be one of the entries in VIDEO_MATTING_QUALITIES; anything else throws a TypeError listing the allowed values. The preset maps to a Quality with preferBitrate enabled. This keeps bitrate selection constrained to supported presets.","triggerScenarios":"Passing a string that is not an exact member of VIDEO_MATTING_QUALITIES — e.g. 'high-quality', '4K', uppercase 'HIGH', or a typo like 'meduim' — through the video matting quality option.","commonSituations":"Config from CLI/JSON where free-text is accepted, casing mismatches after user input, or copying a quality name from a different Remotion API that uses a different enum.","solutions":["Use one of the exact allowed values listed in the error message (e.g. 'low', 'medium', 'high')","Normalize user input: value.trim().toLowerCase() and match against VIDEO_MATTING_QUALITIES before calling","Import and validate against the exported VIDEO_MATTING_QUALITIES list instead of hardcoding strings","Fall back to a default preset when the configured value is unrecognized"],"exampleFix":"// before\nresolveVideoMattingQuality('High');\n// after\nconst preset = String(input).trim().toLowerCase();\nif (!VIDEO_MATTING_QUALITIES.includes(preset)) throw new Error(`Unknown preset: ${preset}`);\nresolveVideoMattingQuality(preset);","handlingStrategy":"validation","validationCode":"const isPreset = (v: unknown): v is VideoMattingQuality =>\n  typeof v === 'string' && (VIDEO_MATTING_QUALITIES as readonly string[]).includes(v);\nif (typeof value === 'string' && !isPreset(value)) throw new TypeError(`Unknown preset: ${value}`);","typeGuard":"const isQualityPreset = (v: unknown): v is QualityPreset =>\n  typeof v === 'string' && (VIDEO_MATTING_QUALITIES as readonly string[]).includes(v);","tryCatchPattern":"try {\n  const quality = resolveVideoMattingQuality(input);\n} catch (err) {\n  if (err instanceof TypeError && err.message.startsWith('The bitrate quality must be one of')) {\n    console.error(`Invalid preset \"${input}\". Allowed: ${err.message}`);\n    return resolveVideoMattingQuality('medium');\n  }\n  throw err;\n}","preventionTips":["Always normalize user input with .trim().toLowerCase() before matching presets","Import VIDEO_MATTING_QUALITIES and validate against it instead of hardcoding strings","Use TypeScript union types so invalid presets fail at compile time","Don't copy quality names from other APIs without checking this package's enum"],"tags":["video-matting","bitrate","enum","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"b2f4e34732f3c6c222ea029413e22dc402218cd7","analyzedAt":"2026-09-09T13:27:51.281Z","contentChangedAt":"2026-09-09T13:27:51.281Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}