{"record":{"id":"9707fd7ddd9ce383","repo":"kubernetes/kops","slug":"error-listing-networks-v","errorCode":null,"errorMessage":"error listing networks: %v","messagePattern":"error listing networks: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resources/gce/gce.go","lineNumber":1214,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnetworkUrls := make(map[string]bool)\n\tfor _, t := range templates {\n\t\tfor _, ni := range t.Properties.NetworkInterfaces {\n\t\t\tif ni.Network != \"\" {\n\t\t\t\tnetworkUrls[ni.Network] = true\n\t\t\t}\n\t\t}\n\t}\n\n\tc := d.gceCloud\n\n\tvar resourceTrackers []*resources.Resource\n\n\tnetworks, err := c.Compute().Networks().List(c.Project())\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error listing networks: %v\", err)\n\t}\n\n\tfor _, o := range networks.Items {\n\t\tif o.Name != gce.SafeTruncatedClusterName(d.clusterName, 63) {\n\t\t\tklog.V(8).Infof(\"skipping network with name %q\", o.Name)\n\t\t\tcontinue\n\t\t}\n\n\t\tif !networkUrls[o.SelfLink] {\n\t\t\tklog.Warningf(\"skipping network %q because it didn't match any instance template\", o.SelfLink)\n\t\t\tcontinue\n\t\t}\n\n\t\tresourceTracker := &resources.Resource{\n\t\t\tName:    o.Name,\n\t\t\tID:      o.Name,\n\t\t\tType:    typeNetwork,\n\t\t\tDeleter: deleteNetwork,","sourceCodeStart":1196,"sourceCodeEnd":1232,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/resources/gce/gce.go#L1196-L1232","documentation":"Fires in listNetworks when the GCE Networks().List call fails while discovering the cluster's VPC network during resource discovery/teardown — a GCE API, credentials, or network failure listing networks.","triggerScenarios":"Networks().List returns 403 (missing compute.networks.list), Compute API disabled or quota/billing issue, invalid project, or transient API failure. Note the code indexes networks.Items without a nil check, so an empty-but-successful response shape change could also matter — but this specific error only fires on the API error path.","commonSituations":"kops credentials with compute rights missing in the target project; wrong project ID in config; Compute Engine API not enabled; GCE API outage during delete cluster.","solutions":["Check GCP credentials and compute.networks.list permission","Retry after transient API errors","Verify the project is correct and accessible"],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"error listing networks: %v\", err)\n// after\nreturn nil, fmt.Errorf(\"error listing networks in project %s: %w\", c.Project(), err)","handlingStrategy":"retry","validationCode":"// preflight with same credentials before mutating anything\n_, err := computeClient.Networks.List(project).Do()\nif err != nil {\n\treturn fmt.Errorf(\"preflight: cannot list networks in %s; check API/permissions: %w\", project, err)\n}","typeGuard":"func isPermissionDenied(err error) bool {\n\tge, ok := err.(*googleapi.Error)\n\treturn ok && ge.Code == 403\n}","tryCatchPattern":"networks, err := c.Compute().Networks().List(c.Project())\nif err != nil {\n\tif isPermissionDenied(err) {\n\t\treturn nil, fmt.Errorf(\"needs compute.networks.list in %s: %w\", c.Project(), err)\n\t}\n\treturn nil, fmt.Errorf(\"error listing networks: %w\", err)\n}","preventionTips":["Run `gcloud compute networks list` with the same credentials as a smoke test.","Enable the Compute API and confirm billing before kops operations.","Verify the project ID in the cluster spec."],"tags":["gce","network","vpc","listing"],"backgroundTag":"gce-api-list-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}