plandex-ai/plandex · error

auth.Current.UserId is empty

Error message

auth.Current.UserId is empty

What it means

SyncCustomModels reads auth.Current.UserId to build the account-scoped custom models path. This error means the CLI attempted to sync custom models before authentication state was populated — auth.Current has no logged-in user, so the target account directory cannot be determined. It is a fail-fast guard, not a network failure.

Source

Thrown at app/cli/lib/custom_models.go:333

				color.New(color.Bold, term.ColorHiRed).Sprint(modelPack.Name)))
		}
	}

	if updated.Len()+added.Len()+deleted.Len() == 0 {
		return false
	}

	fmt.Print(added.String())
	fmt.Print(updated.String())
	fmt.Print(deleted.String())

	return true
}

func SyncCustomModels() error {
	userId := auth.Current.UserId
	if userId == "" {
		return fmt.Errorf("auth.Current.UserId is empty")
	}

	serverModelsInput, err := GetServerModelsInput()
	if err != nil {
		return fmt.Errorf("error getting server models input: %v", err)
	}

	MustSyncCustomModels(GetCustomModelsPath(userId), serverModelsInput)

	return nil
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Log in first (plandex auth or the equivalent login command) so auth.Current.UserId is populated.
  2. Verify the auth session file exists under ~/.plandex and is not corrupt; re-authenticate if it is.
  3. Ensure any code calling SyncCustomModels does so only after auth initialization completes.
  4. If auth is loaded but UserId is still empty, re-install/upgrade the CLI to fix auth-state loading.

Example fix

// before
lib.SyncCustomModels()  # panics into 'auth.Current.UserId is empty'
// after
if auth.Current != nil && auth.Current.UserId != "" {
  lib.SyncCustomModels()
}
Defensive patterns

Strategy: validation

Validate before calling

// Check auth state before calling SyncCustomModels
if auth.Current == nil || auth.Current.UserId == "" {
    term.Error("Not logged in; run the auth/login command first")
    return
}
err := lib.SyncCustomModels()

Type guard

func isLoggedIn() bool {
    return auth.Current != nil && auth.Current.UserId != ""
}

Try / catch

// Go: guard rather than catch; if you must call unconditionally:
if err := lib.SyncCustomModels(); err != nil {
    if strings.Contains(err.Error(), "auth.Current.UserId is empty") {
        term.Error("Please log in first")
        return
    }
    return err
}

Prevention

When it happens

Trigger: Calling SyncCustomModels when no user is logged in (auth.Current is zero-value), when auth session loading failed or was skipped, or when the caller invokes it from a non-authenticated context such as during onboarding or in tests without auth setup.

Common situations: Running a command that syncs models before `plandex auth` / login; expired auth file removed so Current is empty; automation scripts calling the library directly without initializing auth.

Related errors


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