{"record":{"id":"e3f71211069ec48a","repo":"wavetermdev/waveterm","slug":"invalid-app-name-w","errorCode":null,"errorMessage":"invalid app name: %w","messagePattern":"invalid app name: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/waveappstore/waveappstore.go","lineNumber":650,"sourceCode":"\t}\n\n\tif _, err := os.Stat(localDir); os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\n\treturn true, nil\n}\n\n// RenameLocalApp renames a local app by renaming its directories in both the local and draft namespaces.\n// It takes the current app name and the new app name (without namespace prefixes).\n// Both local/[appName] and draft/[appName] will be renamed if they exist.\n// Returns an error if the app doesn't exist in either namespace, if the new name is invalid,\n// or if the new name conflicts with an existing app.\nfunc RenameLocalApp(appName string, newAppName string) error {\n\t// Validate the old app name by constructing a valid appId\n\toldLocalAppId := MakeAppId(AppNSLocal, appName)\n\tif err := ValidateAppId(oldLocalAppId); err != nil {\n\t\treturn fmt.Errorf(\"invalid app name: %w\", err)\n\t}\n\n\t// Validate the new app name by constructing a valid appId\n\tnewLocalAppId := MakeAppId(AppNSLocal, newAppName)\n\tif err := ValidateAppId(newLocalAppId); err != nil {\n\t\treturn fmt.Errorf(\"invalid new app name: %w\", err)\n\t}\n\n\thomeDir := wavebase.GetHomeDir()\n\twaveappsDir := filepath.Join(homeDir, \"waveapps\")\n\n\toldLocalDir := filepath.Join(waveappsDir, AppNSLocal, appName)\n\tnewLocalDir := filepath.Join(waveappsDir, AppNSLocal, newAppName)\n\toldDraftDir := filepath.Join(waveappsDir, AppNSDraft, appName)\n\tnewDraftDir := filepath.Join(waveappsDir, AppNSDraft, newAppName)\n\n\t// Check if at least one of the apps exists\n\tlocalExists := false","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/waveappstore/waveappstore.go#L632-L668","documentation":"RenameLocalApp validates the OLD app name by constructing a local appId and running ValidateAppId. If that fails, the old name itself is invalid and the rename is aborted with \"invalid app name: %w\". This ensures the source directory path being renamed is well-formed before touching the filesystem.","triggerScenarios":"Calling RenameLocalApp(oldName, newName) where oldName is empty, contains illegal characters (slashes, spaces, special chars), or would produce an appId failing ValidateAppId.","commonSituations":"Passing a full appId (\"local:foo\") instead of the bare app name, user-typed names with invalid characters, names copied with trailing whitespace or path separators.","solutions":["Verify the first argument is a bare app name (no namespace prefix, no illegal characters)","Trim and sanitize the name; reject empty strings before calling","Test the name yourself via ValidateAppId(MakeAppId(AppNSLocal, name)) to see the wrapped cause"],"exampleFix":"// before\nRenameLocalApp(\"local:my app\", \"myapp\")\n// after\nRenameLocalApp(\"myapp\", \"myapp2\") // bare, valid names only","handlingStrategy":"validation","validationCode":"func validAppName(name string) error {\n    if name == \"\" || strings.TrimSpace(name) != name { return fmt.Errorf(\"bad app name %q\", name) }\n    _, err := waveappstore.ValidateAppId(waveappstore.MakeAppId(waveappstore.AppNSLocal, name))\n    return err\n}","typeGuard":"func isBareAppName(s string) bool {\n    return s != \"\" && !strings.Contains(s, \":\") && strings.TrimSpace(s) == s\n}","tryCatchPattern":"if err := waveappstore.RenameLocalApp(oldName, newName); err != nil {\n    if strings.Contains(err.Error(), \"invalid app name\") {\n        return fmt.Errorf(\"%q is not a valid app name: %w\", oldName, err)\n    }\n    return err\n}","preventionTips":["Pass bare app names (no namespace prefix) to RenameLocalApp","Trim and reject empty/whitespace names before calling","Pre-validate names with ValidateAppId(MakeAppId(AppNSLocal, name))"],"tags":["go","validation","rename","waveappstore"],"backgroundTag":"invalid-app-name","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}