{"record":{"id":"a5ebe4ad8e115f06","repo":"kubernetes/kops","slug":"error-fetching-subnet-for-patch-w","errorCode":null,"errorMessage":"error fetching subnet for patch: %w","messagePattern":"error fetching subnet for patch: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/subnet.go","lineNumber":187,"sourceCode":"\n\t\t\tchanges.StackType = nil\n\t\t\tchanges.Ipv6AccessType = nil\n\t\t}\n\n\t\tempty := &Subnet{}\n\t\tif !reflect.DeepEqual(empty, changes) {\n\t\t\treturn fmt.Errorf(\"cannot apply changes to Subnet: %v\", changes)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc updateSecondaryRanges(cloud gce.GCECloud, op string, e *Subnet) error {\n\t// We need to refetch to patch it\n\tsubnet, err := cloud.Compute().Subnetworks().Get(cloud.Project(), cloud.Region(), *e.Name)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error fetching subnet for patch: %w\", err)\n\t}\n\n\texpectedRanges := e.SecondaryIpRanges\n\n\tactualRanges := make(map[string]string)\n\tfor _, r := range subnet.SecondaryIpRanges {\n\t\tactualRanges[r.RangeName] = r.IpCidrRange\n\t}\n\n\t// Cannot add and remove ranges in the same call\n\tswitch op {\n\tcase \"add\":\n\t\tpatch := false\n\t\tfor k, v := range expectedRanges {\n\t\t\tif actualRanges[k] != v {\n\t\t\t\tactualRanges[k] = v\n\t\t\t\tsubnet.SecondaryIpRanges = append(subnet.SecondaryIpRanges, &compute.SubnetworkSecondaryRange{\n\t\t\t\t\tRangeName:   k,","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/subnet.go#L169-L205","documentation":"Wrapped error from updateSecondaryRanges when the Subnetworks.Get re-fetch fails. The helper needs the current subnet state to build a patch for secondary ranges; failure means the subnet vanished between discovery and patch, or a permission/API error occurred.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/gcetasks/subnet.go:187 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the wrapped error for the API reason (404, 403, transient)","Verify the subnet still exists in the region","Re-run the apply; transient races usually resolve on retry"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}