{"record":{"id":"27f877a793c5f03c","repo":"plandex-ai/plandex","slug":"error-writing-auth-v","errorCode":null,"errorMessage":"error writing auth: %v","messagePattern":"error writing auth: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/account.go","lineNumber":287,"sourceCode":"\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error setting auth: %v\", err)\n\t}\n\n\torg, err := resolveOrgAuth(res.Orgs, isLocalMode)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error resolving org: %v\", err)\n\t}\n\n\tCurrent.OrgId = org.Id\n\tCurrent.OrgName = org.Name\n\tCurrent.IntegratedModelsMode = org.IntegratedModelsMode\n\n\terr = writeCurrentAuth()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error writing auth: %v\", err)\n\t}\n\n\tfmt.Printf(\"✅ Signed in as %s | Org: %s\\n\", color.New(color.Bold, term.ColorHiGreen).Sprintf(\"<%s> %s\", Current.UserName, Current.Email), color.New(term.ColorHiCyan).Sprint(Current.OrgName))\n\tfmt.Println()\n\n\treturn nil\n}\n\nfunc createAccount(email, pin, host string, isLocalMode bool) error {\n\tvar name string\n\n\tif isLocalMode {\n\t\tname = \"Local Admin\"\n\t} else {\n\t\tvar err error\n\t\tname, err = term.GetUserStringInput(\"Your name:\")\n\n\t\tif err != nil {","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/account.go#L269-L305","documentation":"After setting auth and resolving the org, handleSignInResponse persists the complete session with writeCurrentAuth(); failure there is wrapped as \"error writing auth: %v\". The session was obtained but could not be saved to disk, so sign-in does not complete.","triggerScenarios":"writeCurrentAuth returns an error writing the Current auth struct (token, org id, org name) to the local auth file — permission denied, missing directory, disk full, or serialization failure.","commonSituations":"Read-only filesystem (container/CI), config directory deleted mid-run, disk quota exceeded, or a stale auth file locked/owned by another user after a sudo run.","solutions":["Ensure the auth file's parent directory exists and is writable by the current user.","Fix ownership after prior sudo usage: chown -R $(whoami) ~/.<app>.","Check free disk space and remount read-only volumes.","Retry sign-in once the filesystem is writable."],"exampleFix":"// before\nmkdir: cannot write ~/.myapp/auth.json: Permission denied\n// after\nsudo chown -R $(whoami) ~/.myapp\nmkdir -p ~/.myapp\nmyapp auth login","handlingStrategy":"validation","validationCode":"func canWriteAuthFile(path string) error {\n    dir := filepath.Dir(path)\n    if _, err := os.Stat(dir); err != nil {\n        return fmt.Errorf(\"auth dir missing: %w\", err)\n    }\n    f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, 0o600)\n    if err != nil {\n        return fmt.Errorf(\"auth file not writable: %w\", err)\n    }\n    f.Close()\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := signIn(email, pin, host); err != nil {\n    if strings.Contains(err.Error(), \"error writing auth\") {\n        fmt.Fprintln(os.Stderr, \"Session obtained but could not be saved; fix filesystem permissions/space:\", err)\n    }\n    return err\n}","preventionTips":["Verify the auth file path is writable before login in scripts.","Avoid sudo usage that leaves root-owned auth files.","Watch for read-only root filesystems in containers.","Keep adequate free disk space."],"tags":["auth","filesystem","permissions"],"backgroundTag":"config-write-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}