{"record":{"id":"6be4facb35461acf","repo":"plandex-ai/plandex","slug":"error-syncing-models-v","errorCode":null,"errorMessage":"error syncing models: %v","messagePattern":"error syncing models: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/models_sync.go","lineNumber":86,"sourceCode":"\tfmt.Println()\n\tfor _, change := range changes {\n\t\tfmt.Println(change)\n\t}\n\tfmt.Println()\n\n\tshouldSave, err := term.ConfirmYesNo(\"Save changes now?\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error confirming: %v\", err)\n\t}\n\n\tif !shouldSave {\n\t\treturn nil\n\t}\n\n\tfor _, fn := range onApprove {\n\t\terr := fn()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error syncing models: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":68,"sourceCodeEnd":92,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/models_sync.go#L68-L92","documentation":"Once the user approves, PromptSyncModelsIfNeeded runs each queued sync function (SyncCustomModels, SyncDefaultModelSettings, etc.) and wraps any of their failures as 'error syncing models: %v'. The root cause lives in the wrapped inner error.","triggerScenarios":"Any onApprove function returns an error — e.g. ApplyModelSettings failure (250), UpdateOrgDefaultSettings API failure (251), or custom models sync errors — during the post-approval loop.","commonSituations":"Expired API session mid-sync; corrupted local model/settings files that passed the change check but fail on write; network drop during sync.","solutions":["Read the wrapped inner error to identify which sync step failed (custom models vs default vs plan settings)","Re-authenticate if the inner error is an API/auth failure","Fix the offending local file (JSON validity, permissions) and re-run","Retry the sync after restoring connectivity"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if auth.Current.UserId == \"\" {\n\treturn fmt.Errorf(\"login required before model sync\")\n}\n// verify connectivity\nif err := pingAPI(api.Client); err != nil {\n\treturn fmt.Errorf(\"API unreachable before sync: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := lib.PromptSyncModelsIfNeeded(); err != nil {\n\tvar root error = err\n\t// unwrap to find which sync step failed\n\tfor unwrapped := errors.Unwrap(root); unwrapped != nil; unwrapped = errors.Unwrap(root) {\n\t\troot = unwrapped\n\t}\n\tlog.Printf(\"model sync failed, root cause: %v\", root)\n\treturn err\n}","preventionTips":["Unwrap the error chain to find the failing sync step","Ensure stable connectivity and fresh auth before approving sync","Keep local model/settings files valid so sync steps don't fail midway","Retry sync once after transient network errors"],"tags":["go","sync","error-handling"],"backgroundTag":"sync-operation-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"}