remotion-dev/remotion · error

Could not locate the folder name

Error message

Could not locate the folder name

What it means

Thrown by getFolderNameAttribute (folder-source-edits.ts:238) when a located folder JSX element has no JSX attribute literally named `name` (a JSXAttribute with a JSXIdentifier 'name'). Rename-folder codemods rewrite this attribute's string value, so without it the rename cannot be applied.

Solutions

  1. Write the name attribute explicitly on the <Folder> element: <Folder name="My Folder">
  2. Remove props spreads ({...x}) from Folder elements in the Root file
  3. Rename the folder manually in the editor if the source cannot be normalized

Example fix

// before
const folderProps = {name: "Old Name"};
<Folder {...folderProps}>...</Folder>

// after
<Folder name="Old Name">...</Folder>
Defensive patterns

Strategy: type-guard

Validate before calling

const hasExplicitNameAttr = (folderJsx: string) =>
  /<Folder\s+name="[^"]+"/.test(folderJsx);
if (!hasExplicitNameAttr(folderSnippet)) throw new Error('Folder needs a literal name attribute');

Type guard

const isNamedFolderElement = (el: JSXElement): el is JSXElement & {openingElement: {attributes: [JSXAttribute, ...JSXAttribute[]]}} =>
  el.openingElement.attributes.some(
    (a): a is JSXAttribute => a.type === 'JSXAttribute' && a.name.type === 'JSXIdentifier' && a.name.name === 'name',
  );

Try / catch

try {
  editFolderInSource({codeMod, input});
} catch (e) {
  if (e instanceof Error && e.message === 'Could not locate the folder name') {
    // ask user to add an explicit name attribute, then retry
  }
}

Prevention

When it happens

Trigger: Executing a `rename-folder` codemod against a `<Folder>` element whose name is set via a spread (`{...props}`), a dynamic attribute (`name={folderName}` is fine as attribute but the finder only matches identifier `name` — actually it matches the attribute regardless of value; failure happens when the attribute is absent or spread in), or when the element is not really a Folder component.

Common situations: Root files where <Folder> props are spread from an object constant, custom Folder wrappers that forward props, or hand-minified code that renamed the attribute.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of remotion-dev/remotion@46a3a6bf13 (2026-09-18). Data as JSON: /api/errors/fbb0d72cb27a4329. Report an issue: GitHub.

Appendix: source

Thrown at packages/studio-codemods/src/folder-source-edits.ts:238

		insertionEdit,
		...getInsertImportSourceEdits({
			ast,
			input,
			snapshots,
			prettierConfigOverride: null,
		}),
	];
};

const getFolderNameAttribute = (folder: JSXElement) => {
	const attribute = folder.openingElement.attributes.find(
		(candidate) =>
			candidate.type === 'JSXAttribute' &&
			candidate.name.type === 'JSXIdentifier' &&
			candidate.name.name === 'name',
	);
	if (attribute?.type !== 'JSXAttribute') {
		throw new Error('Could not locate the folder name');
	}

	return attribute;
};

const normalizeBlock = (source: string) => {
	const lines = source.split(/\r?\n/);
	while (lines[0]?.trim() === '') {
		lines.shift();
	}

	while (lines.at(-1)?.trim() === '') {
		lines.pop();
	}

	const indents = lines
		.filter((line) => line.trim() !== '')
		.map((line) => line.match(/^[\t ]*/)?.[0] ?? '');

View on GitHub (pinned to 46a3a6bf13)