{"record":{"id":"1abfb99e16faa018","repo":"plandex-ai/plandex","slug":"error-getting-settings-v","errorCode":null,"errorMessage":"error getting settings: %v","messagePattern":"error getting settings: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/lib/model_settings.go","lineNumber":178,"sourceCode":"\t\treturn false, fmt.Errorf(\"error reading JSON file: %v\", err)\n\t}\n\n\tvar clientModelPackSchemaRoles *shared.ClientModelPackSchemaRoles\n\terr = json.Unmarshal(jsonData, &clientModelPackSchemaRoles)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"error unmarshalling JSON file: %v\", err)\n\t}\n\n\tmodelPackSchemaRoles := clientModelPackSchemaRoles.ToModelPackSchemaRoles()\n\n\tlocalHash, err := modelPackSchemaRoles.Hash()\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"error hashing model pack: %v\", err)\n\t}\n\n\tsettings, apiErr := api.Client.GetSettings(CurrentPlanId, CurrentBranch)\n\tif apiErr != nil {\n\t\treturn false, fmt.Errorf(\"error getting settings: %v\", apiErr)\n\t}\n\n\tserverHash, err := settings.GetModelPack().ToModelPackSchema().ModelPackSchemaRoles.Hash()\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"error hashing model pack: %v\", err)\n\t}\n\n\tif localHash == serverHash {\n\t\treturn false, nil\n\t}\n\n\terr = WriteModelSettingsFile(path, settings)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"error writing model settings file: %v\", err)\n\t}\n\n\treturn true, nil\n}","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/lib/model_settings.go#L160-L196","documentation":"This error wraps a failure from api.Client.GetSettings(CurrentPlanId, CurrentBranch), the API call that fetches the plan's server-side settings. The client wraps any transport, auth, or API-level error with this message. It means the local/server hash comparison could not proceed because the server settings were unreachable or rejected.","triggerScenarios":"GetSettings fails due to: no network / DNS failure, expired or invalid auth token, the plan ID or branch not existing server-side (404), server 5xx, or a request timeout.","commonSituations":"Working offline or behind a corporate proxy; API key rotated or expired session; CurrentPlanId/CurrentBranch stale after the plan was deleted or renamed; API server temporarily down during maintenance.","solutions":["Check network connectivity and any proxy configuration (HTTP_PROXY/HTTPS_PROXY).","Re-authenticate (e.g. re-login) if the token is expired; the inner apiErr will show 401/403.","Verify CurrentPlanId and CurrentBranch are valid — run the command that lists plans/branches to confirm they exist.","Retry after a transient outage; add retry-with-backoff around GetSettings for flaky networks."],"exampleFix":"// before: single attempt, wraps err (note: in SyncPlanModelSettings sibling code the wrong variable is wrapped)\nsettings, apiErr := api.Client.GetSettings(CurrentPlanId, CurrentBranch)\nif apiErr != nil {\n    return false, fmt.Errorf(\"error getting settings: %v\", apiErr)\n}\n// after: retry transient failures\nvar settings *shared.Settings\nvar apiErr error\nfor i := 0; i < 3; i++ {\n    settings, apiErr = api.Client.GetSettings(CurrentPlanId, CurrentBranch)\n    if apiErr == nil {\n        break\n    }\n    time.Sleep(time.Duration(1<<i) * time.Second)\n}\nif apiErr != nil {\n    return false, fmt.Errorf(\"error getting settings: %w\", apiErr)\n}","handlingStrategy":"retry","validationCode":"// Pre-flight connectivity/auth check before calling\nreq, _ := http.NewRequest(\"GET\", apiBase+\"/health\", nil)\nresp, err := http.DefaultClient.Do(req)\nif err != nil {\n    return fmt.Errorf(\"API unreachable, GetSettings will fail: %w\", err)\n}\nresp.Body.Close()","typeGuard":"func isAuthError(err error) bool {\n    return err != nil && (strings.Contains(err.Error(), \"401\") || strings.Contains(err.Error(), \"403\"))\n}","tryCatchPattern":"updated, err := lib.SaveLatestPlanModelSettingsIfNeeded()\nif err != nil && strings.Contains(err.Error(), \"error getting settings\") {\n    if isAuthError(err) {\n        return reloginAndRetry()\n    }\n    return retryWithBackoff(3, time.Second, retry)\n}","preventionTips":["Re-login before long sessions; tokens expire.","Verify plan ID/branch exist after deletions or renames.","Handle offline mode explicitly instead of calling sync.","Wrap API calls with bounded retry/backoff."],"tags":["go","network","api","http-client"],"backgroundTag":"api-request-failed","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"}