{"record":{"id":"99683a975cbf90ff","repo":"plandex-ai/plandex","slug":"error-getting-custom-models-v","errorCode":null,"errorMessage":"error getting custom models: %v","messagePattern":"error getting custom models: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/settings_helpers.go","lineNumber":23,"sourceCode":"\t\"encoding/json\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\tshared \"plandex-shared\"\n\n\t\"github.com/jmoiron/sqlx\"\n)\n\nfunc GetPlanSettings(plan *Plan) (settings *shared.PlanSettings, err error) {\n\tplanDir := getPlanDir(plan.OrgId, plan.Id)\n\tsettingsPath := filepath.Join(planDir, \"settings.json\")\n\n\tresult, err := GetApiCustomModels(plan.OrgId)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error getting custom models: %v\", err)\n\t}\n\n\tdefer func() {\n\t\tif settings != nil {\n\t\t\tsettings.Configure(result.CustomModelPacks, result.CustomModels, result.CustomProviders, os.Getenv(\"PLANDEX_CLOUD\") != \"\")\n\t\t}\n\t}()\n\n\tbytes, err := os.ReadFile(settingsPath)\n\n\tif os.IsNotExist(err) || len(bytes) == 0 {\n\t\tlog.Printf(\"GetPlanSettings - no settings file found for plan %s - checking org defaults\", plan.Id)\n\t\t// see if org has default settings\n\t\tdefaultSettings, err := GetOrgDefaultSettings(plan.OrgId)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error getting org default settings: %v\", err)\n\t\t}","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/settings_helpers.go#L5-L41","documentation":"GetPlanSettings first calls GetApiCustomModels(plan.OrgId) to load the org's custom models/packs/providers. If that fails, the error is wrapped as this message. The failure is in the custom-models lookup, not in reading plan settings itself.","triggerScenarios":"Calling GetPlanSettings (directly or via LoadContexts, UpdateContexts, TellPlanHandler, BuildPlanHandler, etc.) when GetApiCustomModels fails for the org — e.g. the org's custom models store is missing/corrupt, or a DB (sqlx) error occurs during that lookup.","commonSituations":"Corrupted or missing custom models data for the org; database connectivity problems; an org id that doesn't exist in the models store.","solutions":["Unwrap the inner error — fix the underlying GetApiCustomModels failure first.","Verify orgId is valid and its custom models data exists and parses.","Check database connectivity/health if the custom models store is DB-backed.","Restore or rebuild the org's custom models config from backup."],"exampleFix":"// before\nsettings, err := db.GetPlanSettings(plan)\n// after\nsettings, err := db.GetPlanSettings(plan)\nif err != nil && strings.Contains(err.Error(), \"error getting custom models\") {\n    log.Printf(\"custom models lookup failed for org %s: %v\", plan.OrgId, err)\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"settings, err := GetPlanSettings(plan)\nif err != nil && strings.Contains(err.Error(), \"error getting custom models\") {\n    log.Printf(\"proceeding with builtin defaults; custom models unavailable: %v\", err)\n    settings = &shared.PlanSettings{ModelPackName: shared.DefaultModelPack.Name}\n}","preventionTips":["Verify the org's custom models data loads (via the equivalent API) before plan operations.","Monitor DB connectivity health if custom models are DB-backed.","Validate orgId at request boundaries."],"tags":["go","settings","models"],"backgroundTag":"model-config-load-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}