{"record":{"id":"881d2bea23ed2034","repo":"remotion-dev/remotion","slug":"outputtarget-and-outputwritable-cannot-both-be-spe","errorCode":null,"errorMessage":"outputTarget and outputWritable cannot both be specified for a video layer","messagePattern":"outputTarget and outputWritable cannot both be specified for a video layer","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/video-matting/src/create-video-layer-output.ts","lineNumber":36,"sourceCode":"export type CreatedVideoLayerOutput<F extends OutputFormat> = {\n\toutput: Output<F, VideoLayerMediabunnyTarget>;\n\tfinalize: () => Promise<VideoLayerOutput>;\n\tcancel: () => Promise<void>;\n\tdiscard: () => Promise<void>;\n};\n\nexport const createVideoLayerOutput = async <F extends OutputFormat>({\n\tformat,\n\toptions,\n}: {\n\tformat: F;\n\toptions: VideoLayerOutputOptions | undefined;\n}): Promise<CreatedVideoLayerOutput<F>> => {\n\tif (\n\t\toptions?.outputTarget !== undefined &&\n\t\toptions.outputWritable !== undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t'outputTarget and outputWritable cannot both be specified for a video layer',\n\t\t);\n\t}\n\n\tlet webFsTarget: WebFsVideoLayerTarget | null = null;\n\tlet target: VideoLayerMediabunnyTarget;\n\tlet outputMode: 'arraybuffer' | 'web-fs' | 'writable';\n\tconst outputWritable = options?.outputWritable;\n\tlet outputWritableWriter: WritableStreamDefaultWriter<StreamTargetChunk> | null =\n\t\tnull;\n\tlet outputWritableClosePromise: Promise<void> | null = null;\n\tlet outputWritableAbortPromise: Promise<void> | null = null;\n\tlet outputWritableWasClosed = false;\n\tconst getOutputWritableWriter = () => {\n\t\tif (outputWritable === undefined) {\n\t\t\tthrow new Error('Expected a caller-provided output WritableStream');\n\t\t}\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/remotion-dev/remotion/blob/b2f4e34732f3c6c222ea029413e22dc402218cd7/packages/video-matting/src/create-video-layer-output.ts#L18-L54","documentation":"createVideoLayerOutput rejects options where both outputTarget and outputWritable are provided, since a video layer output may have exactly one destination. The two options are mutually exclusive by design.","triggerScenarios":"Calling createVideoLayerOutput({outputTarget: ..., outputWritable: ...}) with both fields set in the options object.","commonSituations":"Merging config objects/spreading defaults where both keys end up defined; refactoring code that switched from one option to the other without removing the old key.","solutions":["Specify only outputTarget OR only outputWritable, not both","When merging option objects, explicitly unset the unused key (undefined won't help — delete it or build the object conditionally)","Pick outputWritable when you want a writable stream, outputTarget for file/URL targets"],"exampleFix":"// before\ncreateVideoLayerOutput({outputTarget: target, outputWritable: writable})\n// after\ncreateVideoLayerOutput({outputWritable: writable})","handlingStrategy":"validation","validationCode":"if (opts.outputTarget !== undefined && opts.outputWritable !== undefined) {\n  throw new Error('Specify only one of outputTarget / outputWritable');\n}","typeGuard":"const hasExactlyOneOutput = (o: {outputTarget?: unknown; outputWritable?: unknown}): boolean =>\n  (o.outputTarget !== undefined) !== (o.outputWritable !== undefined);","tryCatchPattern":"try {\n  const out = await createVideoLayerOutput(options);\n} catch (err) {\n  if (String(err).includes('cannot both be specified')) {\n    // strip one key and retry, e.g. prefer outputWritable\n  }\n}","preventionTips":["Build options objects conditionally instead of spreading multiple defaults","When migrating between outputTarget and outputWritable, remove the old key","Type options so consumers see a union of the two shapes","Sanitize config-derived option objects before passing them"],"tags":["video","options","validation"],"backgroundTag":"mutually-exclusive-options","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"}