plandex-ai/plandex · error

Model id is required

Error message

Model id is required

What it means

Request validation in UpsertCustomModelsHandler: a custom model in the payload has an empty ModelId. Pure input validation — the model cannot be referenced without an id, so the request is rejected with 400 before any writes.

Source

Thrown at app/server/handlers/models.go:80

	if !hasDuplicates {
		http.Error(w, "Has duplicates: "+errMsg, http.StatusBadRequest)
		return
	}

	for _, provider := range modelsInput.CustomProviders {
		if provider.Name == "" {
			msg := "Provider name is required"
			log.Println(msg)
			http.Error(w, msg, http.StatusBadRequest)
			return
		}
	}

	for _, model := range modelsInput.CustomModels {
		if model.ModelId == "" {
			msg := "Model id is required"
			log.Println(msg)
			http.Error(w, msg, http.StatusBadRequest)
			return
		}

		if shared.BuiltInBaseModelsById[model.ModelId] != nil {
			msg := fmt.Sprintf("%s is a built-in base model id, so it can't be used for a custom model", model.ModelId)
			log.Println(msg)
			http.Error(w, msg, http.StatusUnprocessableEntity)
			return
		}
	}

	for _, modelPack := range modelsInput.CustomModelPacks {
		if modelPack.Name == "" {
			msg := "Model pack name is required"
			log.Println(msg)
			http.Error(w, msg, http.StatusBadRequest)
			return
		}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Set a unique non-empty modelId on every object in the customModels array
  2. Validate model ids client-side before sending the request
  3. Check the request JSON for entries where modelId is "" or absent
  4. Avoid model ids that collide with built-in base model ids (that raises a separate 422 error)

Example fix

// before
{"customModels": [{"provider": "openai", "baseUrl": "..."}]}
// after
{"customModels": [{"modelId": "my-model", "provider": "openai", "baseUrl": "..."}]}
Defensive patterns

Strategy: validation

Validate before calling

for i, m := range input.CustomModels {
    if m.ModelId == "" {
        return fmt.Errorf("customModels[%d].modelId is required", i)
    }
}

Type guard

func modelIdentified(m *shared.CustomModel) bool { return m != nil && m.ModelId != "" }

Prevention

When it happens

Trigger: POSTing to the custom models upsert endpoint with a CustomModels element whose modelId field is missing or empty.

Common situations: Hand-editing a models.json and dropping the modelId line; generating models from a loop where the id variable is empty; copy-paste of a model template where only baseUrl/apiKey were filled in.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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