remotion-dev/remotion · error · TypeError

The "content" must be a string or Uint8Array, but you passed

Error message

The "content" must be a string or Uint8Array, but you passed a value of type ${typeof content}

What it means

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`.

Source

Thrown at packages/core/src/validation/validate-artifact.ts:23

		throw new TypeError(
			`The "filename" must be a string, but you passed a value of type ${typeof filename}`,
		);
	}

	if (filename.trim() === '') {
		throw new Error('The `filename` must not be empty');
	}

	if (!filename.match(/^([0-9a-zA-Z-!_.*'()/:&$@=;+,?]+)/g)) {
		throw new Error(
			'The `filename` must match "/^([0-9a-zA-Z-!_.*\'()/:&$@=;+,?]+)/g". Use forward slashes only, even on Windows.',
		);
	}
};

const validateContent = (content: unknown) => {
	if (typeof content !== 'string' && !(content instanceof Uint8Array)) {
		throw new TypeError(
			`The "content" must be a string or Uint8Array, but you passed a value of type ${typeof content}`,
		);
	}

	if (typeof content === 'string' && content.trim() === '') {
		throw new Error('The `content` must not be empty');
	}
};

export const validateRenderAsset = (artifact: TRenderAsset) => {
	// We don't have validation for it yet
	if (artifact.type !== 'artifact') {
		return;
	}

	validateArtifactFilename(artifact.filename);

	if (artifact.contentType === 'thumbnail') {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Set `content` to a `string` (text artifacts) or a `Uint8Array` (binary artifacts).
  2. Stringify structured data: `content: JSON.stringify(obj)`.
  3. Wrap buffers/ArrayBuffers: `new Uint8Array(arrayBuffer)` or `new Uint8Array(nodeBuffer.buffer, offset, length)`.
  4. If content is genuinely absent, do not register the artifact rather than passing null.

Example fix

// before
{type:'artifact', filename:'data.json', contentType:'json', content: {a: 1}}
// after
{type:'artifact', filename:'data.json', contentType:'json', content: JSON.stringify({a: 1})}
Defensive patterns

Strategy: validation

Validate before calling

function checkArtifactContent(c) {
  if (typeof c !== 'string' && !(c instanceof Uint8Array)) {
    throw new TypeError('content must be string or Uint8Array, got ' + typeof c);
  }
}

Type guard

const isArtifactContent = (c) => typeof c === 'string' || c instanceof Uint8Array;

Prevention

When it happens

Trigger: 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`).

Common situations: 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.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/1c357fe4e359136a. Report an issue: GitHub.