{"record":{"id":"4e8e46d9bf45d5e7","repo":"wavetermdev/waveterm","slug":"failed-to-create-destination-directory-w","errorCode":null,"errorMessage":"failed to create destination directory: %w","messagePattern":"failed to create destination directory: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/waveappstore/waveappstore.go","lineNumber":399,"sourceCode":"\t}\n\n\tappDir, err := GetAppDir(appId)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfromPath, err := validateAndResolveFilePath(appDir, fromFileName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid source path: %w\", err)\n\t}\n\n\ttoPath, err := validateAndResolveFilePath(appDir, toFileName)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid destination path: %w\", err)\n\t}\n\n\tif err := os.MkdirAll(filepath.Dir(toPath), 0755); err != nil {\n\t\treturn fmt.Errorf(\"failed to create destination directory: %w\", err)\n\t}\n\n\tif err := os.Rename(fromPath, toPath); err != nil {\n\t\treturn fmt.Errorf(\"failed to rename file: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc FormatGoFile(appId string, fileName string) error {\n\tif err := ValidateAppId(appId); err != nil {\n\t\treturn fmt.Errorf(\"invalid appId: %w\", err)\n\t}\n\n\tappDir, err := GetAppDir(appId)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/waveappstore/waveappstore.go#L381-L417","documentation":"After validating the destination path, RenameAppFile creates the destination's parent directory with os.MkdirAll before renaming. If that mkdir fails, the error is wrapped as \"failed to create destination directory\". This usually reflects filesystem-level problems (permissions, full disk, path conflicts) rather than bad input.","triggerScenarios":"os.MkdirAll(filepath.Dir(toPath), 0755) fails while renaming an app file into a new subdirectory — e.g. parent dir is read-only, disk is full, or a non-directory file exists at that path.","commonSituations":"~/waveapps owned by another user or on a read-only mount; quota/disk-full on the volume holding the home directory; destination nested directory name colliding with an existing regular file.","solutions":["Check permissions on ~/waveapps/<ns>/<app> and its parent (need write + execute for the running user)","Verify free disk space with df on the home-directory volume","Check that no regular file exists at filepath.Dir(toPath) which blocks directory creation","Run the app/terminal process as a user that owns the waveapps tree"],"exampleFix":"// shell check before retry\nls -ld ~/waveapps/<ns>/<app> && df -h ~\n// fix ownership\nsudo chown -R \"$USER\" ~/waveapps","handlingStrategy":"try-catch","validationCode":"appDir, _ := GetAppDir(appId)\ntoPath := filepath.Join(appDir, filepath.Clean(toFileName))\nparent := filepath.Dir(toPath)\nif fi, err := os.Stat(parent); err == nil && !fi.IsDir() {\n\treturn errors.New(\"destination parent exists as a file\")\n}\nif err := unix.Access(parent, unix.W_OK); err != nil {\n\treturn fmt.Errorf(\"no write access to %s: %w\", parent, err)","typeGuard":null,"tryCatchPattern":"if err := RenameAppFile(appId, from, to); err != nil {\n\tif strings.Contains(err.Error(), \"failed to create destination directory\") {\n\t\t// surface as environment/permissions problem, not user input error\n\t\treturn fmt.Errorf(\"filesystem error creating dir for %q: %w\", to, err)\n\t}\n\treturn err\n}","preventionTips":["Keep ~/waveapps owned and writable by the user running the app","Monitor disk space on the home-directory volume","Avoid renaming files into directories whose path collides with an existing file"],"tags":["filesystem","permissions","go"],"backgroundTag":"mkdir-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}