plandex-ai/plandex · error

error setting auth: %v

Error message

error setting auth: %v

What it means

setAuth persists the selected account plus resolved org (Id, Name, trial flag, integrated-models mode) into the local auth store. This error wraps any failure from that write. Because setAuth operates on local state, this usually means the auth file could not be written rather than a server problem.

Source

Thrown at app/cli/auth/account.go:94

		return fmt.Errorf("error listing orgs: %v", apiErr.Msg)
	}

	org, err := resolveOrgAuth(orgs, selectedAuth.IsLocalMode)

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

	err = setAuth(&shared.ClientAuth{
		ClientAccount:        *selected,
		OrgId:                org.Id,
		OrgName:              org.Name,
		OrgIsTrial:           org.IsTrial,
		IntegratedModelsMode: org.IntegratedModelsMode,
	})

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

	_, apiErr = apiClient.GetOrgSession()

	if apiErr != nil {
		return fmt.Errorf("error getting org session: %v", apiErr.Msg)
	}

	fmt.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))
	fmt.Println()

	if !term.IsRepl {
		term.PrintCmds("", "")
	}

	return nil
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Check permissions on the Plandex config directory/auth file (e.g. ~/.plandex) and ensure the current user can write it.
  2. Free disk space / fix quota if the disk is full, then retry sign-in.
  3. If the auth file is corrupted, remove it and re-run `plandex signIn` to regenerate it.
  4. In containers/CI, mount the config directory as a writable volume.

Example fix

// before
-r-------- 1 otheruser auth ~/.plandex/auth.json  (write fails: permission denied)
// after
chown -R $USER ~/.plandex && chmod 600 ~/.plandex/auth.json
Defensive patterns

Strategy: validation

Validate before calling

f, err := os.OpenFile(authPath, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
    return fmt.Errorf("auth store not writable (%s): %v; fix permissions before sign-in", authPath, err)
}
f.Close()

Try / catch

if err := auth.SelectOrSignInOrCreate(); err != nil {
    if strings.Contains(err.Error(), "error setting auth") {
        if errors.Is(err, fs.ErrPermission) || errors.Is(err, fs.ErrPermissionWrapped) {
            return fmt.Errorf("cannot write auth file: check ownership/permissions on the plandex config dir")
        }
    }
    return err
}

Prevention

When it happens

Trigger: setAuth returns an error while writing the auth JSON to disk — unwritable config directory, permission denied on ~/.plandex/auth.json, disk full, or serialization failure of the ClientAuth payload.

Common situations: Read-only home directory or container filesystem; restrictive file permissions left by a previous run running as a different user; disk quota exceeded; corrupted config directory.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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