{"record":{"id":"e4644cc276f0a611","repo":"plandex-ai/plandex","slug":"error-loading-accounts-v","errorCode":null,"errorMessage":"error loading accounts: %v","messagePattern":"error loading accounts: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/auth/account.go","lineNumber":18,"sourceCode":"package auth\n\nimport (\n\t\"fmt\"\n\t\"plandex-cli/term\"\n\n\tshared \"plandex-shared\"\n\n\t\"github.com/fatih/color\"\n)\n\nconst AddAccountOption = \"Add another account\"\n\nfunc SelectOrSignInOrCreate() error {\n\taccounts, err := loadAccounts()\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error loading accounts: %v\", err)\n\t}\n\n\tif len(accounts) == 0 {\n\t\terr := promptSignInNewAccount()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error signing in to new account: %v\", err)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tvar options []string\n\tfor _, account := range accounts {\n\t\toptions = append(options, fmt.Sprintf(\"<%s> %s\", account.UserName, account.Email))\n\t}\n\n\toptions = append(options, AddAccountOption)\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/auth/account.go#L1-L36","documentation":"SelectOrSignInOrCreate in app/cli/auth/account.go wraps any failure from loadAccounts() — reading the locally stored account/auth files — as 'error loading accounts: %v'. It means the CLI could not read or parse the on-disk account store before presenting the account selection UI, so the underlying I/O or deserialization error is preserved in the wrapped message.","triggerScenarios":"Calling SelectOrSignInOrCreate (directly or via promptInitialAuth/signIn) when loadAccounts() fails — e.g. the accounts file is missing in an unexpected way, unreadable due to permissions, corrupted JSON, or the storage directory cannot be accessed.","commonSituations":"HOME directory misconfigured so auth files land in a nonexistent path; permissions changed by another user or run with sudo vs. normal user; accounts file corrupted by a crashed write or manual edit; upgrading/downgrading CLI changed the storage format.","solutions":["Inspect the wrapped cause (%v) in the message to identify the actual I/O or parse failure.","Check permissions and existence of the CLI's auth/accounts storage directory (typically under your home config dir) and fix ownership with chown/chmod.","If the file is corrupted, back it up and remove/rename it so the CLI re-creates it, then sign in again.","Ensure HOME (or XDG config path) is set correctly, especially when running under sudo, cron, or containers."],"exampleFix":"// before\nsudo plandex sign-in   # runs as root, can't read user's accounts file -> error loading accounts\n// after\nplandex sign-in         # run as the owning user, accounts file readable","handlingStrategy":"validation","validationCode":"// Before invoking auth flows, ensure the accounts store is readable\naccountsPath := authStorePath() // CLI's accounts file location\nif info, err := os.Stat(accountsPath); err != nil {\n    if !os.IsNotExist(err) {\n        log.Fatalf(\"accounts file exists but is inaccessible: %v\", err) // fix perms first\n    }\n} else if info.IsDir() {\n    log.Fatal(\"accounts path is a directory; storage is corrupted\")\n}","typeGuard":"func isLoadAccountsError(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"error loading accounts:\")\n}","tryCatchPattern":"if err := auth.SelectOrSignInOrCreate(); err != nil {\n    if isLoadAccountsError(err) {\n        // back up and remove the corrupted accounts file so it is re-created\n        os.Rename(authStorePath(), authStorePath()+\".bak\")\n        err = auth.SelectOrSignInOrCreate()\n    }\n    if err != nil {\n        log.Fatal(err)\n    }\n}","preventionTips":["Don't run the CLI under sudo if accounts were created as a normal user","Keep HOME/XDG paths consistent across shells and CI","Never hand-edit the accounts/auth file while the CLI is running","Back up the auth store before upgrading the CLI"],"tags":["auth","filesystem","go","config"],"backgroundTag":"auth-store-unreadable","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"}