{"record":{"id":"2baae29db2fdaa7e","repo":"wavetermdev/waveterm","slug":"failed-to-check-if-new-local-app-exists-w","errorCode":null,"errorMessage":"failed to check if new local app exists: %w","messagePattern":"failed to check if new local app exists: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/waveappstore/waveappstore.go","lineNumber":690,"sourceCode":"\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"failed to check local app: %w\", err)\n\t}\n\n\tif _, err := os.Stat(oldDraftDir); err == nil {\n\t\tdraftExists = true\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"failed to check draft app: %w\", err)\n\t}\n\n\tif !localExists && !draftExists {\n\t\treturn fmt.Errorf(\"app '%s' does not exist in local or draft namespace\", appName)\n\t}\n\n\t// Check if new app name already exists in either namespace\n\tif _, err := os.Stat(newLocalDir); err == nil {\n\t\treturn fmt.Errorf(\"local app '%s' already exists\", newAppName)\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"failed to check if new local app exists: %w\", err)\n\t}\n\n\tif _, err := os.Stat(newDraftDir); err == nil {\n\t\treturn fmt.Errorf(\"draft app '%s' already exists\", newAppName)\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"failed to check if new draft app exists: %w\", err)\n\t}\n\n\t// Rename local app if it exists\n\tif localExists {\n\t\tif err := os.Rename(oldLocalDir, newLocalDir); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to rename local app: %w\", err)\n\t\t}\n\t}\n\n\t// Rename draft app if it exists\n\tif draftExists {\n\t\tif err := os.Rename(oldDraftDir, newDraftDir); err != nil {","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/waveappstore/waveappstore.go#L672-L708","documentation":"If the existence check for the prospective local destination directory fails with an error other than NotExist, RenameLocalApp aborts with \"failed to check if new local app exists: %w\". This avoids wrongly concluding the name is free when the stat itself failed.","triggerScenarios":"os.Stat(newLocalDir) returns a non-ENOENT error: permission denied on ~/waveapps/local, I/O error, or an unreadable parent directory.","commonSituations":"Permission-restricted waveapps tree, destination directory owned by another user, failing disk or unmounted volume during the rename.","solutions":["Fix permissions on ~/waveapps/local so the process can stat entries there","Verify the volume is mounted and healthy","Run under the account that owns the waveapps directory"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"localDir := filepath.Join(wavebase.GetHomeDir(), \"waveapps\", \"local\")\nif err := os.Access(localDir, os.R_OK); err != nil {\n    return fmt.Errorf(\"cannot read local dir: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := waveappstore.RenameLocalApp(oldName, newName); err != nil {\n    var pe *fs.PathError\n    if strings.Contains(err.Error(), \"failed to check if new local app exists\") && errors.As(err, &pe) {\n        return fmt.Errorf(\"stat failed on %s: %w\", pe.Path, pe.Err)\n    }\n    return err\n}","preventionTips":["Keep ~/waveapps/local readable by the process user","Verify volume mounts and disk health before bulk app operations","Avoid running as a user without access to the waveapps tree"],"tags":["go","filesystem","permissions","os-stat"],"backgroundTag":"filesystem-permission-denied","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}