plandex-ai/plandex · error

error storing account: %v

Error message

error storing account: %v

What it means

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.

Source

Thrown at app/cli/auth/state.go:40

			return nil, fmt.Errorf("error reading accounts.json: %v", err)
		}
	}

	var accounts []*shared.ClientAccount
	err = json.Unmarshal(bytes, &accounts)

	if err != nil {
		return nil, fmt.Errorf("error unmarshalling accounts.json: %v", err)
	}

	return accounts, nil
}

func setAuth(auth *shared.ClientAuth) error {
	err := storeAccount(&auth.ClientAccount)

	if err != nil {
		return fmt.Errorf("error storing account: %v", err)
	}

	Current = auth

	err = writeCurrentAuth()

	if err != nil {
		return fmt.Errorf("error writing auth: %v", err)
	}

	return nil
}

func storeAccount(toStore *shared.ClientAccount) error {
	accounts, err := loadAccounts()

	if err != nil {
		return fmt.Errorf("error loading accounts: %v", err)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Fix permissions/ownership on ~/.plandex and accounts.json (chown/chmod)
  2. Free disk space if the write failed with ENOSPC
  3. Read the nested cause in the message: for load errors fix accounts.json, for write errors fix filesystem access
  4. Sign in again after fixing; the store is rebuilt on successful auth

Example fix

// before
error storing account: error writing accounts: open ~/.plandex/accounts.json: permission denied
// after
$ sudo chown -R $USER ~/.plandex
$ plandex-cli sign-in
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the store is writable before signing in
if err := os.WriteFile(fs.HomeAccountsPath+".wtest", []byte(""), 0o600); err != nil {
    return fmt.Errorf("~/.plandex not writable: %v", err)
}
os.Remove(fs.HomeAccountsPath + ".wtest")

Try / catch

if err := setAuth(auth); err != nil {
    if strings.Contains(err.Error(), "error storing account") {
        // inspect nested cause: loading (fix accounts.json) or writing (fix perms/disk)
    }
    return err
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/18799b8a9cb92c9d. Report an issue: GitHub.