{"record":{"id":"86330a2041871d17","repo":"Netflix/chaosmonkey","slug":"retrieve-cloud-provider-failed-86330a","errorCode":null,"errorMessage":"retrieve cloud provider failed","messagePattern":"retrieve cloud provider failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spinnaker/spinnaker.go","lineNumber":304,"sourceCode":"\n\tasg := D.ASGName(data.Name)\n\tinstances := make([]D.InstanceID, len(data.Instances))\n\tfor i, instance := range data.Instances {\n\t\tinstances[i] = D.InstanceID(instance.Name)\n\t}\n\n\treturn asg, instances, nil\n\n}\n\n// GetApp implements deploy.Deployment.GetApp\nfunc (s Spinnaker) GetApp(appName string) (*D.App, error) {\n\t// data arg is a map like {accountName: {clusterName: {regionName: {asgName: [instanceId]}}}}\n\tdata := make(D.AppMap)\n\tfor account, clusters := range s.clusters(appName) {\n\t\tcloudProvider, err := s.CloudProvider(account)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"retrieve cloud provider failed\")\n\t\t}\n\t\taccount := D.AccountName(account)\n\t\tdata[account] = D.AccountInfo{\n\t\t\tCloudProvider: cloudProvider,\n\t\t\tClusters:      make(map[D.ClusterName]map[D.RegionName]map[D.ASGName][]D.InstanceID),\n\t\t}\n\t\tfor _, clusterName := range clusters {\n\t\t\tclusterName := D.ClusterName(clusterName)\n\t\t\tdata[account].Clusters[clusterName] = make(map[D.RegionName]map[D.ASGName][]D.InstanceID)\n\t\t\tasgs, err := s.asgs(appName, string(account), string(clusterName))\n\t\t\tif err != nil {\n\t\t\t\tlog.Printf(\"WARNING: could not retrieve asgs for app:%s account:%s cluster:%s : %v\", appName, account, clusterName, err)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor _, asg := range asgs {\n\n\t\t\t\t// We don't terminate instances in disabled ASGs\n\t\t\t\tif asg.Disabled {","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/Netflix/chaosmonkey/blob/eaa28fb761c0ebe8644d1333e5d164e9cc3071e9/spinnaker/spinnaker.go#L286-L322","documentation":"Spinnaker.GetApp throws this when s.CloudProvider(account) fails for one of the accounts configured for the app. It wraps the underlying error from CloudProvider (which calls the internal account(name) lookup), meaning the account's cloud provider could not be retrieved from the Spinnaker API.","triggerScenarios":"Calling GetApp (directly or via Apps) when the Spinnaker /accounts endpoint is unreachable, returns non-JSON, or the account name from s.clusters(appName) does not exist in Spinnaker — the inner error is wrapped with this message.","commonSituations":"Stale app configuration referencing an account deleted from Spinnaker (clouddriver account removed/renamed); Spinnaker gate down; typo in account name in app cluster naming convention; permissions preventing the accounts listing.","solutions":["Inspect the wrapped inner error (use %v on the chain) to see whether it was network, JSON, or 'account name doesn't exist'.","Verify the account name exists: query the Spinnaker /accounts endpoint or UI and compare with the app's configured accounts.","Re-check the app's cluster naming convention that yields the account name — stale configs after account renames are common.","Ensure Spinnaker gate is reachable and credentials are valid.","If one account is intentionally missing, remove it from the app's configuration or skip it upstream."],"exampleFix":"// before\ncloudProvider, err := s.CloudProvider(account)\nif err != nil {\n    return nil, errors.Wrap(err, \"retrieve cloud provider failed\")\n}\n// after (caller-side check)\n_, err := sp.GetApp(\"myapp\")\nif err != nil {\n    log.Printf(\"GetApp failed: %+v\", err) // print full chain to see the root cause\n}","handlingStrategy":"try-catch","validationCode":"// verify the account exists before GetApp\naccounts, err := fetchSpinnakerAccountNames(baseURL, client) // GET /accounts\nif err != nil {\n    return err\n}\naccountSet := make(map[string]bool, len(accounts))\nfor _, a := range accounts {\n    accountSet[a] = true\n}\nfor _, acct := range configuredAccounts {\n    if !accountSet[acct] {\n        return fmt.Errorf(\"account %q configured for app but missing in spinnaker\", acct)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Go: unwrap the chain to find the root cause\napp, err := sp.GetApp(appName)\nif err != nil {\n    root := errors.Cause(err)\n    switch {\n    case strings.Contains(root.Error(), \"doesn't exist\"):\n        log.Printf(\"stale account config: %v\", err) // fix app config\n    default:\n        log.Printf(\"spinnaker account lookup failed: %+v\", err)\n    }\n    return app, err\n}","preventionTips":["Keep app cluster-naming configs in sync with Spinnaker account definitions","Unwrap errors with %+v / errors.Cause to see the root cause","Validate account names at config load time","Handle per-account failures gracefully like Apps does (log and continue)"],"tags":["spinnaker","api","configuration","account"],"backgroundTag":"account-not-found","analyzedSha":"eaa28fb761c0ebe8644d1333e5d164e9cc3071e9","analyzedAt":"2026-09-03T17:04:39.020Z","contentChangedAt":"2026-09-03T17:04:39.020Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}