plandex-ai/plandex · error

error getting server models input: %v

Error message

error getting server models input: %v

What it means

The `plandex models custom` command fetches the server's models input in a goroutine via lib.GetServerModelsInput() and reports failures over an errCh channel as 'error getting server models input: %v'. GetServerModelsInput combines the server's available models with any user custom model config; it fails if the underlying API call fails or the custom models file/config cannot be read or parsed.

Source

Thrown at app/cli/cmd/models.go:107

	Args:    cobra.MaximumNArgs(1),
	Run:     customModelsNotImplemented,
}

func manageCustomModels(cmd *cobra.Command, args []string) {
	auth.MustResolveAuthWithOrg()

	term.StartSpinner("")

	var serverModelsInput *shared.ModelsInput
	var defaultConfig *shared.PlanConfig

	errCh := make(chan error, 2)

	go func() {
		var err error
		serverModelsInput, err = lib.GetServerModelsInput()
		if err != nil {
			errCh <- fmt.Errorf("error getting server models input: %v", err)
			return
		}
		errCh <- nil
	}()

	go func() {
		var apiErr *shared.ApiError
		defaultConfig, apiErr = api.Client.GetDefaultPlanConfig()
		if apiErr != nil {
			errCh <- fmt.Errorf("error getting default config: %v", apiErr.Msg)
			return
		}
		errCh <- nil
	}()

	for i := 0; i < 2; i++ {
		err := <-errCh
		if err != nil {

View on GitHub (pinned to e2d772072e)

Solutions

  1. Validate the custom models config JSON (e.g. with `jq . <file>` or `plandex models custom --file <path>` after fixing) and correct syntax/schema errors.
  2. Fix the underlying error printed inside the message: re-authenticate for 401s, check server connectivity/daemon for network errors.
  3. Temporarily run `plandex models available` to confirm the server model list endpoint works independently of custom config.
  4. Update the CLI and server to matching versions if a models-spec mismatch is reported.

Example fix

// before (custom models JSON)
{"models": [{"name": "gpt-x", "provider": "openai"}]}
// after — role is required and provider must be known
{"models": [{"name": "gpt-x", "provider": "openai", "role": "plan"}]}
Defensive patterns

Strategy: validation

Validate before calling

# validate custom models JSON before running the command
FILE=~/.plandex/custom_models.json
jq empty "$FILE" && echo "config valid" || echo "fix JSON syntax in $FILE"

Type guard

func validModelsInput(in *shared.ModelsInput) bool {
    return in != nil && len(in.Models) > 0
}

Try / catch

serverModelsInput, err := lib.GetServerModelsInput()
if err != nil {
    var apiErr *shared.ApiError
    if errors.As(err, &apiErr) && apiErr.Status == 401 {
        // prompt re-auth and retry once
    }
    term.OutputErrorAndExit(fmt.Sprintf("server models input unavailable: %v", err))
}

Prevention

When it happens

Trigger: Running `plandex models custom` when lib.GetServerModelsInput() returns an error: the ListAvailableModels API call fails (server unreachable, expired auth), or local custom model config is missing/malformed and cannot be merged into the server models input.

Common situations: Invalid JSON in a custom models config file the user edited by hand; referencing an unknown provider or role in custom config; expired session or unreachable Plandex server; version mismatch where server models spec is newer than the CLI expects.

Related errors


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