plandex-ai/plandex · warning

Custom model not found

Error message

Custom model not found

What it means

GetCustomModelHandler returns 404 with body 'Custom model not found' when db.GetCustomModel returns successfully but with a nil result — i.e. no custom model row matches the given modelId for the authenticated org. The lookup is scoped to the org, so models in other orgs are invisible.

Source

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

func GetCustomModelHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for GetCustomModelHandler")

	auth := Authenticate(w, r, true)
	if auth == nil {
		return
	}

	id := mux.Vars(r)["modelId"]

	res, err := db.GetCustomModel(auth.OrgId, id)
	if err != nil {
		log.Printf("Error fetching custom model: %v\n", err)
		http.Error(w, "Failed to fetch custom model: "+err.Error(), http.StatusInternalServerError)
		return
	}

	if res == nil {
		http.Error(w, "Custom model not found", http.StatusNotFound)
		return
	}

	err = json.NewEncoder(w).Encode(res.ToApi())
	if err != nil {
		log.Printf("Error encoding custom model: %v\n", err)
		http.Error(w, fmt.Sprintf("Error encoding custom model: %v", err), http.StatusInternalServerError)
		return
	}

	log.Println("Successfully fetched custom model")
}

func ListCustomModelsHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for ListCustomModelsHandler")

	auth := Authenticate(w, r, true)
	if auth == nil {

View on GitHub (pinned to e2d772072e)

Solutions

  1. Confirm the exact modelId via the list custom models endpoint for the current org
  2. Re-create the custom model if it was deleted by a previous upsert/import
  3. Verify you are authenticated against the org that owns the model
  4. Check you're passing the stored id, not a display name or pack name
Defensive patterns

Strategy: fallback

Validate before calling

// confirm the id exists before fetching
ids := fetchCustomModelIds(org)
if !contains(ids, modelId) {
    return fmt.Errorf("model %q not present in org; pick from %v", modelId, ids)
}

Try / catch

// 404 is deterministic — handle as empty result, never retry
if resp.StatusCode == 404 && strings.Contains(bodyText, "Custom model not found") {
    return nil, ErrModelNotFound // fall back to built-in defaults
}

Prevention

When it happens

Trigger: GET /custom-models/{modelId} (or equivalent route) with a modelId that doesn't exist in the org: deleted model, id from a different org, wrong id type (name vs internal id), or typo in the path parameter.

Common situations: Stale client cache referencing a model removed by a full-replace upsert (upsert deletes any stored model not present in the input); copying an id from another environment/org; confusing the model id with the pack or provider name.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — 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/040101a5acdb2a9c. Report an issue: GitHub.