{"record":{"id":"040101a5acdb2a9c","repo":"plandex-ai/plandex","slug":"custom-model-not-found","errorCode":null,"errorMessage":"Custom model not found","messagePattern":"Custom model not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"app/server/handlers/models.go","lineNumber":359,"sourceCode":"func GetCustomModelHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for GetCustomModelHandler\")\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {\n\t\treturn\n\t}\n\n\tid := mux.Vars(r)[\"modelId\"]\n\n\tres, err := db.GetCustomModel(auth.OrgId, id)\n\tif err != nil {\n\t\tlog.Printf(\"Error fetching custom model: %v\\n\", err)\n\t\thttp.Error(w, \"Failed to fetch custom model: \"+err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tif res == nil {\n\t\thttp.Error(w, \"Custom model not found\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\terr = json.NewEncoder(w).Encode(res.ToApi())\n\tif err != nil {\n\t\tlog.Printf(\"Error encoding custom model: %v\\n\", err)\n\t\thttp.Error(w, fmt.Sprintf(\"Error encoding custom model: %v\", err), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tlog.Println(\"Successfully fetched custom model\")\n}\n\nfunc ListCustomModelsHandler(w http.ResponseWriter, r *http.Request) {\n\tlog.Println(\"Received request for ListCustomModelsHandler\")\n\n\tauth := Authenticate(w, r, true)\n\tif auth == nil {","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/handlers/models.go#L341-L377","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the exact modelId via the list custom models endpoint for the current org","Re-create the custom model if it was deleted by a previous upsert/import","Verify you are authenticated against the org that owns the model","Check you're passing the stored id, not a display name or pack name"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// confirm the id exists before fetching\nids := fetchCustomModelIds(org)\nif !contains(ids, modelId) {\n    return fmt.Errorf(\"model %q not present in org; pick from %v\", modelId, ids)\n}","typeGuard":null,"tryCatchPattern":"// 404 is deterministic — handle as empty result, never retry\nif resp.StatusCode == 404 && strings.Contains(bodyText, \"Custom model not found\") {\n    return nil, ErrModelNotFound // fall back to built-in defaults\n}","preventionTips":["Refresh cached model lists after every upsert (full-replace deletes omitted models)","Distinguish stored ids from display names/pack names","Verify org context when reusing ids across environments","Treat 404 as a signal to re-sync the org's custom model config"],"tags":["http-404","not-found","custom-models"],"backgroundTag":"resource-not-found","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}