{"record":{"id":"cb2ea5d858b7bd38","repo":"wavetermdev/waveterm","slug":"rename-failed-errortext","errorCode":null,"errorMessage":"Rename failed: ${errorText}","messagePattern":"Rename failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/app/view/preview/preview-directory-utils.tsx","lineNumber":103,"sourceCode":"    model: PreviewModel,\n    path: string,\n    newPath: string,\n    isDir: boolean,\n    setErrorMsg: (msg: ErrorMsg) => void\n) {\n    fireAndForget(async () => {\n        try {\n            let srcuri = await model.formatRemoteUri(path, globalStore.get);\n            if (isDir) {\n                srcuri += \"/\";\n            }\n            await model.env.rpc.FileMoveCommand(TabRpcClient, {\n                srcuri,\n                desturi: await model.formatRemoteUri(newPath, globalStore.get),\n            });\n        } catch (e) {\n            const errorText = `${e}`;\n            console.warn(`Rename failed: ${errorText}`);\n            const errorMsg: ErrorMsg = {\n                status: \"Rename Failed\",\n                text: `${e}`,\n            };\n            setErrorMsg(errorMsg);\n        }\n        model.refreshCallback();\n    });\n}\n\nexport function handleFileDelete(\n    model: PreviewModel,\n    path: string,\n    recursive: boolean,\n    setErrorMsg: (msg: ErrorMsg) => void\n) {\n    fireAndForget(async () => {\n        const formattedPath = await model.formatRemoteUri(path, globalStore.get);","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/frontend/app/view/preview/preview-directory-utils.tsx#L85-L121","documentation":"handleRename calls the FileMoveCommand RPC to rename a preview directory/file; if the RPC rejects, the error is stringified, logged as 'Rename failed: <e>' and shown to the user via an ErrorMsg. It reports a backend-side failure of the move/rename operation.","triggerScenarios":"FileMoveCommand rejects: destination URI invalid or already exists, source missing, permission denied, or the backend/filesystem returns an error for srcuri -> desturi.","commonSituations":"Renaming to a name that collides with an existing file; renaming on a read-only or disconnected remote; stale preview state pointing at a deleted source; invalid characters in the new name.","solutions":["Read the ErrorMsg text/status shown in the preview for the backend reason (e.g. permission denied, already exists)","Verify the destination name is valid and does not already exist","Confirm the source file still exists and refresh the preview","Check filesystem/remote permissions and connectivity, then retry"],"exampleFix":"// before\nconst errorText = `${e}`;\nconsole.warn(`Rename failed: ${errorText}`);\n// after\nconst errorText = `${e}`;\nconsole.warn(`Rename failed: ${errorText} (src=${srcuri})`);\nif (errorText.includes(\"already exists\")) {\n    setErrorMsg({ status: \"Rename Failed\", text: \"A file with that name already exists\", level: \"warning\" });\n    return;\n}","handlingStrategy":"try-catch","validationCode":"// before renaming, validate the target name client-side\nconst desturi = await model.formatRemoteUri(newPath, globalStore.get);\nif (!newPath || newPath.includes('/') === false && await uriExists(desturi)) {\n    setErrorMsg({ status: 'Rename Failed', text: 'Destination already exists' });\n    return;\n}","typeGuard":"function isFileSystemRpcError(e: unknown): e is { message?: string } {\n    return e instanceof Error || (typeof e === 'object' && e !== null && 'message' in e);\n}","tryCatchPattern":"try {\n    await model.env.rpc.FileMoveCommand(TabRpcClient, { srcuri, desturi });\n} catch (e) {\n    const errorText = `${e}`;\n    console.warn(`Rename failed: ${errorText}`);\n    setErrorMsg({ status: 'Rename Failed', text: errorText });\n}","preventionTips":["Check the destination name for collisions before calling FileMoveCommand","Refresh preview state so srcuri is not stale (source already moved/deleted)","Confirm write permission on the parent directory of the destination","Surface the stringified backend error to the user instead of swallowing it"],"tags":["rpc","filesystem","rename","preview"],"backgroundTag":"file-move-rpc-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}