{"record":{"id":"1c357fe4e359136a","repo":"remotion-dev/remotion","slug":"the-content-must-be-a-string-or-uint8array-but","errorCode":null,"errorMessage":"The \"content\" must be a string or Uint8Array, but you passed a value of type ${typeof content}","messagePattern":"The \"content\" must be a string or Uint8Array, but you passed a value of type (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/validation/validate-artifact.ts","lineNumber":23,"sourceCode":"\t\tthrow new TypeError(\n\t\t\t`The \"filename\" must be a string, but you passed a value of type ${typeof filename}`,\n\t\t);\n\t}\n\n\tif (filename.trim() === '') {\n\t\tthrow new Error('The `filename` must not be empty');\n\t}\n\n\tif (!filename.match(/^([0-9a-zA-Z-!_.*'()/:&$@=;+,?]+)/g)) {\n\t\tthrow new Error(\n\t\t\t'The `filename` must match \"/^([0-9a-zA-Z-!_.*\\'()/:&$@=;+,?]+)/g\". Use forward slashes only, even on Windows.',\n\t\t);\n\t}\n};\n\nconst validateContent = (content: unknown) => {\n\tif (typeof content !== 'string' && !(content instanceof Uint8Array)) {\n\t\tthrow new TypeError(\n\t\t\t`The \"content\" must be a string or Uint8Array, but you passed a value of type ${typeof content}`,\n\t\t);\n\t}\n\n\tif (typeof content === 'string' && content.trim() === '') {\n\t\tthrow new Error('The `content` must not be empty');\n\t}\n};\n\nexport const validateRenderAsset = (artifact: TRenderAsset) => {\n\t// We don't have validation for it yet\n\tif (artifact.type !== 'artifact') {\n\t\treturn;\n\t}\n\n\tvalidateArtifactFilename(artifact.filename);\n\n\tif (artifact.contentType === 'thumbnail') {","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/core/src/validation/validate-artifact.ts#L5-L41","documentation":"Remotion validates the `content` field of a render asset whose `type` is `'artifact'` and whose `contentType` is not `'thumbnail'`. The content must be a `string` or a `Uint8Array`; any other type is rejected with a TypeError because the renderer can only serialize text or raw bytes to disk. The check lives in `validateContent`, invoked from `validateRenderAsset`.","triggerScenarios":"A `TRenderAsset` of `type:'artifact'` (non-thumbnail) is registered/fetched with `content` set to a value that is neither a string nor a `Uint8Array` — e.g. a plain object, number, boolean, null, plain Array, or an `ArrayBuffer`/`DataView` (these are NOT `instanceof Uint8Array`).","commonSituations":"Programmatically generating a JSON sidecar artifact and assigning the parsed object instead of `JSON.stringify(obj)`; passing a `number`; converting media with an ArrayBuffer directly instead of a typed array; defaulting content to `null` as a placeholder.","solutions":["Set `content` to a `string` (text artifacts) or a `Uint8Array` (binary artifacts).","Stringify structured data: `content: JSON.stringify(obj)`.","Wrap buffers/ArrayBuffers: `new Uint8Array(arrayBuffer)` or `new Uint8Array(nodeBuffer.buffer, offset, length)`.","If content is genuinely absent, do not register the artifact rather than passing null."],"exampleFix":"// before\n{type:'artifact', filename:'data.json', contentType:'json', content: {a: 1}}\n// after\n{type:'artifact', filename:'data.json', contentType:'json', content: JSON.stringify({a: 1})}","handlingStrategy":"validation","validationCode":"function checkArtifactContent(c) {\n  if (typeof c !== 'string' && !(c instanceof Uint8Array)) {\n    throw new TypeError('content must be string or Uint8Array, got ' + typeof c);\n  }\n}","typeGuard":"const isArtifactContent = (c) => typeof c === 'string' || c instanceof Uint8Array;","tryCatchPattern":null,"preventionTips":["Treat artifact content as a serialization boundary: always emit string or Uint8Array.","Remember an ArrayBuffer is not a Uint8Array — wrap it.","Never use null as a placeholder content value."],"tags":["validation","artifact","render-asset","type","renderer"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}