{"record":{"id":"a0d27ab7509382ba","repo":"plandex-ai/plandex","slug":"error-writing-auth-v-a0d27a","errorCode":null,"errorMessage":"error writing auth: %v","messagePattern":"error writing auth: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/auth.go","lineNumber":132,"sourceCode":"func RefreshAuth() error {\n\tif Current == nil {\n\t\treturn fmt.Errorf(\"error refreshing auth: auth not loaded\")\n\t}\n\n\torg, apiErr := apiClient.GetOrgSession()\n\n\tif apiErr != nil {\n\t\treturn fmt.Errorf(\"error getting org session: %v\", apiErr.Msg)\n\t}\n\n\tCurrent.OrgName = org.Name\n\tCurrent.OrgIsTrial = org.IsTrial\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\treturn nil\n}\n","sourceCodeStart":114,"sourceCodeEnd":137,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/auth.go#L114-L137","documentation":"After a successful GetOrgSession refresh, RefreshAuth persists the updated auth via writeCurrentAuth (writes auth.json under fs.HomeAuthPath). If persisting fails (I/O error) it is wrapped as this error. The refresh succeeded remotely but could not be saved locally.","triggerScenarios":"writeCurrentAuth fails writing to HOME: disk full, permission denied on ~/.plandex-auth (or equivalent path), read-only filesystem, or the auth file directory missing.","commonSituations":"Read-only container/CI filesystem; HOME set to a non-writable path; disk quota exceeded; SELinux/permissions after upgrading the CLI run under a different user; running in a sandbox that blocks writes outside the workspace.","solutions":["Check disk space (df -h) and free space or quotas","Verify permissions/ownership of HOME and the auth file path (ls -la ~/.plandex-auth*)","Ensure HOME points to a writable directory when running in containers/CI","Inspect the wrapped inner error (%v) — it names the exact OS-level cause"],"exampleFix":"// before\nexport HOME=/ro-fs/home # read-only mount\n// after\nexport HOME=/home/user && plandex sign in","handlingStrategy":"validation","validationCode":"if info, err := os.Stat(filepath.Dir(fs.HomeAuthPath)); err != nil || !info.IsDir() {\n\treturn fmt.Errorf(\"auth dir missing or unwritable: %v\", err)\n}\nif err := unix.Access(fs.HomeAuthPath, unix.W_OK); err != nil {\n\treturn fmt.Errorf(\"auth file not writable: %v\", err)\n}","typeGuard":"func authWritable() bool {\n\tf, err := os.OpenFile(fs.HomeAuthPath, os.O_WRONLY|os.O_CREATE, 0600)\n\tif err != nil { return false }\n\tf.Close()\n\treturn true\n}","tryCatchPattern":"if _, err := auth.RefreshAuth(); err != nil {\n\tif strings.Contains(err.Error(), \"writing auth\") {\n\t\t// check disk/permissions, then retry once\n\t\tfmt.Fprintln(os.Stderr, \"check disk space and HOME permissions:\", err)\n\t\t_, err = auth.RefreshAuth()\n\t}\n\tif err != nil { term.OutputErrorAndExit(\"%v\", err) }\n}","preventionTips":["Ensure HOME is writable in containers/CI","Monitor disk space and quotas","Fix file ownership/permissions after user changes (chown, 0600)","Don't run the CLI on read-only mounts"],"tags":["filesystem","auth","persistence"],"backgroundTag":"file-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"}