plandex-ai/plandex · error

error checking custom models: %v

Error message

error checking custom models: %v

What it means

The function validates the user's custom models file via CustomModelsCheckLocalChanges and wraps any failure as 'error checking custom models: %v'. This indicates the custom models file at GetCustomModelsPath(userId) could not be read or parsed.

Source

Thrown at app/cli/lib/models_sync.go:24

	"plandex-cli/term"

	"github.com/fatih/color"
)

func PromptSyncModelsIfNeeded() error {
	var changes []string
	var onApprove []func() error

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

	customModelsPath := GetCustomModelsPath(userId)

	customModelsRes, err := CustomModelsCheckLocalChanges(customModelsPath)
	if err != nil {
		return fmt.Errorf("error checking custom models: %v", err)
	}

	if customModelsRes.HasLocalChanges {
		changes = append(
			changes,
			fmt.Sprintf("%s → %s", color.New(term.ColorHiCyan, color.Bold).Sprint("Custom models"), customModelsPath))

		onApprove = append(onApprove, SyncCustomModels)
	}

	defaultModelSettingsRes, err := ModelSettingsCheckLocalChanges(DefaultModelSettingsPath)
	if err != nil {
		return fmt.Errorf("error checking default model settings: %v", err)
	}

	if defaultModelSettingsRes.HasLocalChanges {
		changes = append(
			changes,

View on GitHub (pinned to e2d772072e)

Solutions

  1. Inspect the custom models file at GetCustomModelsPath(userId) and fix its JSON syntax
  2. Restore the file from backup or delete it to regenerate defaults
  3. Check file permissions on the custom models path
  4. Check disk space / I/O health if read errors persist

Example fix

// validate before syncing
if _, err := os.Stat(customModelsPath); err == nil {
	var m map[string]any
	if err := json.Unmarshal(b, &m); err != nil {
		// repair or reset the file before calling PromptSyncModelsIfNeeded
	}
}
Defensive patterns

Strategy: validation

Validate before calling

path := lib.GetCustomModelsPath(userId)
if b, err := os.ReadFile(path); err == nil {
	var v any
	if err := json.Unmarshal(b, &v); err != nil {
		return fmt.Errorf("custom models file invalid at %s: %w", path, err)
	}
}

Try / catch

if err := lib.PromptSyncModelsIfNeeded(); err != nil {
	if strings.Contains(err.Error(), "error checking custom models") {
		// back up and reset the custom models file, then retry
	}
	return err
}

Prevention

When it happens

Trigger: CustomModelsCheckLocalChanges(customModelsPath) errors — file unreadable (permissions), invalid JSON, or an I/O error while comparing local changes.

Common situations: Corrupted or hand-edited custom models JSON; partially written file after a crash; wrong HOME so the per-user path resolves oddly; restrictive file permissions.

Related errors


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