{"record":{"id":"302768eaa947dbad","repo":"plandex-ai/plandex","slug":"error-checking-custom-models-v","errorCode":null,"errorMessage":"error checking custom models: %v","messagePattern":"error checking custom models: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/models_sync.go","lineNumber":24,"sourceCode":"\t\"plandex-cli/term\"\n\n\t\"github.com/fatih/color\"\n)\n\nfunc PromptSyncModelsIfNeeded() error {\n\tvar changes []string\n\tvar onApprove []func() error\n\n\tuserId := auth.Current.UserId\n\tif userId == \"\" {\n\t\treturn fmt.Errorf(\"auth.Current.UserId is empty\")\n\t}\n\n\tcustomModelsPath := GetCustomModelsPath(userId)\n\n\tcustomModelsRes, err := CustomModelsCheckLocalChanges(customModelsPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error checking custom models: %v\", err)\n\t}\n\n\tif customModelsRes.HasLocalChanges {\n\t\tchanges = append(\n\t\t\tchanges,\n\t\t\tfmt.Sprintf(\"%s → %s\", color.New(term.ColorHiCyan, color.Bold).Sprint(\"Custom models\"), customModelsPath))\n\n\t\tonApprove = append(onApprove, SyncCustomModels)\n\t}\n\n\tdefaultModelSettingsRes, err := ModelSettingsCheckLocalChanges(DefaultModelSettingsPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error checking default model settings: %v\", err)\n\t}\n\n\tif defaultModelSettingsRes.HasLocalChanges {\n\t\tchanges = append(\n\t\t\tchanges,","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/models_sync.go#L6-L42","documentation":"The function validates the user's custom models file via CustomModelsCheckLocalChanges and wraps any failure as 'error checking custom models: %v'. This indicates the custom models file at GetCustomModelsPath(userId) could not be read or parsed.","triggerScenarios":"CustomModelsCheckLocalChanges(customModelsPath) errors — file unreadable (permissions), invalid JSON, or an I/O error while comparing local changes.","commonSituations":"Corrupted or hand-edited custom models JSON; partially written file after a crash; wrong HOME so the per-user path resolves oddly; restrictive file permissions.","solutions":["Inspect the custom models file at GetCustomModelsPath(userId) and fix its JSON syntax","Restore the file from backup or delete it to regenerate defaults","Check file permissions on the custom models path","Check disk space / I/O health if read errors persist"],"exampleFix":"// validate before syncing\nif _, err := os.Stat(customModelsPath); err == nil {\n\tvar m map[string]any\n\tif err := json.Unmarshal(b, &m); err != nil {\n\t\t// repair or reset the file before calling PromptSyncModelsIfNeeded\n\t}\n}","handlingStrategy":"validation","validationCode":"path := lib.GetCustomModelsPath(userId)\nif b, err := os.ReadFile(path); err == nil {\n\tvar v any\n\tif err := json.Unmarshal(b, &v); err != nil {\n\t\treturn fmt.Errorf(\"custom models file invalid at %s: %w\", path, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := lib.PromptSyncModelsIfNeeded(); err != nil {\n\tif strings.Contains(err.Error(), \"error checking custom models\") {\n\t\t// back up and reset the custom models file, then retry\n\t}\n\treturn err\n}","preventionTips":["Back up custom models files before manual edits","Validate JSON with a linter before saving","Check file permissions after syncing machines","Keep one CLI version to avoid schema drift"],"tags":["go","config","file-io","json"],"backgroundTag":"config-file-parse-error","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"}