{"record":{"id":"18799b8a9cb92c9d","repo":"plandex-ai/plandex","slug":"error-storing-account-v","errorCode":null,"errorMessage":"error storing account: %v","messagePattern":"error storing account: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/state.go","lineNumber":40,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"error reading accounts.json: %v\", err)\n\t\t}\n\t}\n\n\tvar accounts []*shared.ClientAccount\n\terr = json.Unmarshal(bytes, &accounts)\n\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error unmarshalling accounts.json: %v\", err)\n\t}\n\n\treturn accounts, nil\n}\n\nfunc setAuth(auth *shared.ClientAuth) error {\n\terr := storeAccount(&auth.ClientAccount)\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error storing account: %v\", err)\n\t}\n\n\tCurrent = auth\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\nfunc storeAccount(toStore *shared.ClientAccount) error {\n\taccounts, err := loadAccounts()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error loading accounts: %v\", err)","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/state.go#L22-L58","documentation":"setAuth persists the authenticated account by calling storeAccount, and wraps any storeAccount failure in this error. storeAccount itself already wraps loadAccounts failures as \"error loading accounts\", so this error most commonly surfaces from marshal or the accounts.json write step failing after accounts loaded fine.","triggerScenarios":"setAuth (called by SelectOrSignInOrCreate, handleSignInResponse, createAccount) invokes storeAccount and it returns an error — inner causes include \"error loading accounts\" (see error 49), \"error marshalling accounts\", or \"error writing accounts\" (disk full, permission denied on ~/.plandex/accounts.json).","commonSituations":"Read-only home directory or root-owned ~/.plandex; disk full during write; corrupted accounts.json triggering the nested load failure; concurrent CLI processes racing on the same file.","solutions":["Fix permissions/ownership on ~/.plandex and accounts.json (chown/chmod)","Free disk space if the write failed with ENOSPC","Read the nested cause in the message: for load errors fix accounts.json, for write errors fix filesystem access","Sign in again after fixing; the store is rebuilt on successful auth"],"exampleFix":"// before\nerror storing account: error writing accounts: open ~/.plandex/accounts.json: permission denied\n// after\n$ sudo chown -R $USER ~/.plandex\n$ plandex-cli sign-in","handlingStrategy":"try-catch","validationCode":"// verify the store is writable before signing in\nif err := os.WriteFile(fs.HomeAccountsPath+\".wtest\", []byte(\"\"), 0o600); err != nil {\n    return fmt.Errorf(\"~/.plandex not writable: %v\", err)\n}\nos.Remove(fs.HomeAccountsPath + \".wtest\")","typeGuard":null,"tryCatchPattern":"if err := setAuth(auth); err != nil {\n    if strings.Contains(err.Error(), \"error storing account\") {\n        // inspect nested cause: loading (fix accounts.json) or writing (fix perms/disk)\n    }\n    return err\n}","preventionTips":["Keep ~/.plandex owned by your user (avoid sudo runs)","Maintain free disk space","Unwrap and read the nested cause in the error message before acting","Avoid running multiple CLI instances concurrently against the same store"],"tags":["filesystem","persistence","accounts-json","auth"],"backgroundTag":"file-permission-denied","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"}