{"record":{"id":"25ea4dd411d81752","repo":"remotion-dev/remotion","slug":"oldrelativepath-does-not-exist","errorCode":null,"errorMessage":"${oldRelativePath} does not exist","messagePattern":"(.+?) does not exist","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser-studio/src/browser-studio-project-controller.ts","lineNumber":532,"sourceCode":"\t\tgetFileSource: (fileName) =>\n\t\t\tPromise.resolve(getFileSource({fileName, project: getProject()})),\n\t\tredo,\n\t\tresetHistory: () => {\n\t\t\tundoStack.length = 0;\n\t\t\tredoStack.length = 0;\n\t\t\temit(getUndoRedoEvent());\n\t\t},\n\t\trenameStaticFile: ({oldRelativePath, newRelativePath}) => {\n\t\t\ttry {\n\t\t\t\tconst oldPath = normalizePublicFilePath(oldRelativePath);\n\t\t\t\tconst newPath = normalizePublicFilePath(newRelativePath);\n\t\t\t\tif (oldPath === newPath) {\n\t\t\t\t\treturn Promise.resolve({success: true});\n\t\t\t\t}\n\n\t\t\t\tconst publicFiles = getCanonicalPublicFiles(getProject());\n\t\t\t\tif (publicFiles[oldPath] === undefined) {\n\t\t\t\t\tthrow new Error(`${oldRelativePath} does not exist`);\n\t\t\t\t}\n\n\t\t\t\tif (publicFiles[newPath] !== undefined) {\n\t\t\t\t\tthrow new Error(`${newRelativePath} already exists`);\n\t\t\t\t}\n\n\t\t\t\tapplyMutation({\n\t\t\t\t\tfileName: oldPath,\n\t\t\t\t\tnodePathMutationFiles: null,\n\t\t\t\t\tmutate: (project) => {\n\t\t\t\t\t\tconst nextPublicFiles = getCanonicalPublicFiles(project);\n\t\t\t\t\t\tnextPublicFiles[newPath] = nextPublicFiles[oldPath];\n\t\t\t\t\t\tdelete nextPublicFiles[oldPath];\n\t\t\t\t\t\treturn {...project, publicFiles: nextPublicFiles};\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn Promise.resolve({success: true});\n\t\t\t} catch (error) {","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/browser-studio/src/browser-studio-project-controller.ts#L514-L550","documentation":"During renameStaticFile, Browser Studio looks up the normalized old path in the project's canonical publicFiles map. If that key is absent, the source of the rename does not exist and the operation is rejected before any mutation is applied. The check uses the canonical (normalized) form, so the path must match exactly after normalization.","triggerScenarios":"Calling renameStaticFile with an oldRelativePath that is not a current key in project.publicFiles (after normalization). Happens when the file was already renamed, deleted, never existed, or when casing/leading-slash differs from the stored key.","commonSituations":"Stale UI state after another tab mutated the project; file already renamed/deleted in the same session; path-string mismatch (leading '/', case sensitivity on case-sensitive stores); race where the file is removed between read and rename.","solutions":["Refresh the current publicFiles list right before offering/performing the rename.","Match the oldRelativePath to an existing key exactly (no leading slash, identical casing).","Disable the rename action in the UI when the selected file no longer exists.","Handle a 'not found' outcome gracefully instead of crashing the flow."],"exampleFix":"// before\nrenameStaticFile({oldRelativePath: 'gone.png', newRelativePath: 'renamed.png'});\n\n// after\nconst files = getCanonicalPublicFiles(project);\nif (!files['gone.png']) {\n\trefreshFileList();\n\treturn;\n}\nrenameStaticFile({oldRelativePath: 'gone.png', newRelativePath: 'renamed.png'});","handlingStrategy":"validation","validationCode":"// Before renameStaticFile\nconst canonical = getCanonicalPublicFiles(project);\nconst oldKey = normalizePublicFilePath(oldRelativePath);\nif (canonical[oldKey] === undefined) {\n  refreshPublicFiles(); // re-sync UI state\n  return; // do not call rename\n}","typeGuard":"const isExistingPublicFile = (project: VirtualProject, path: string): boolean =>\n  Object.prototype.hasOwnProperty.call(getCanonicalPublicFiles(project), normalizePublicFilePath(path));","tryCatchPattern":"try {\n  await ops.renameStaticFile({oldRelativePath, newRelativePath});\n} catch (err) {\n  if (String(err?.message ?? '').endsWith('does not exist')) {\n    refreshPublicFiles(); // file list is stale\n    return;\n  }\n  throw err;\n}","preventionTips":["Refresh the public-files list immediately before offering a rename action.","Disable rename in the UI when the selected source is no longer present.","Always compare keys in their normalized (canonical) form, not the raw string.","Treat a 'does not exist' result as a soft 'refresh and retry' signal, not a hard crash."],"tags":["public-files","browser-studio","rename","state","stale-ui"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}