{"record":{"id":"cae428babc5fd5c0","repo":"GoogleContainerTools/skaffold","slug":"converting-resource-version-to-integer-w","errorCode":null,"errorMessage":"converting resource version to integer: %w","messagePattern":"converting resource version to integer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/kubernetes/portforward/pod_forwarder.go","lineNumber":148,"sourceCode":"\t\t\t\toutput.Yellow.Fprintf(p.output, \"Forwarding container %s/%s to local port %d.\\n\", pod.Name, c.Name, entry.localPort)\n\t\t\t}\n\t\t\tif pe, ok := p.entryManager.forwardedResources.Load(entry.key()); ok {\n\t\t\t\tprevEntry := pe.(*portForwardEntry)\n\t\t\t\t// Check if this is a new generation of pod\n\t\t\t\tif entry.resourceVersion > prevEntry.resourceVersion {\n\t\t\t\t\tp.entryManager.Terminate(prevEntry)\n\t\t\t\t}\n\t\t\t}\n\t\t\tp.entryManager.forwardPortForwardEntry(ctx, p.output, entry)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (p *WatchingPodForwarder) podForwardingEntry(resourceVersion, containerName, portName, ownerReference string, resource latest.PortForwardResource) (*portForwardEntry, error) {\n\trv, err := strconv.Atoi(resourceVersion)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"converting resource version to integer: %w\", err)\n\t}\n\tentry := newPortForwardEntry(rv, resource, resource.Name, containerName, portName, ownerReference, 0, true)\n\n\t// If we have, return the current entry\n\toe, ok := p.entryManager.forwardedResources.Load(entry.key())\n\n\tif ok {\n\t\toldEntry := oe.(*portForwardEntry)\n\t\tentry.localPort = oldEntry.localPort\n\t\treturn entry, nil\n\t}\n\n\t// retrieve an open port on the host\n\tentry.localPort = retrieveAvailablePort(resource.Address, resource.Port.IntVal, &p.entryManager.forwardedPorts)\n\n\treturn entry, nil\n}\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/kubernetes/portforward/pod_forwarder.go#L130-L166","documentation":"podForwardingEntry converts the pod's resourceVersion string to an int via strconv.Atoi before constructing a portForwardEntry. Kubernetes resource versions are normally numeric strings, so failure means the value is empty or malformed. The error is wrapped as \"converting resource version to integer\" and propagates to portForwardPod.","triggerScenarios":"strconv.Atoi(resourceVersion) fails when called from portForwardPod with a pod whose ResourceVersion is \"\", \"0\"-prefixed garbage, or otherwise non-numeric — usually a pod object fetched from a stale or synthetic informer cache.","commonSituations":"Running against fake clientsets in tests that omit ResourceVersion; clusters/proxies returning incomplete pod metadata; skaffold watch events firing on a pod object mid-deletion whose metadata was already stripped.","solutions":["Check the pod's ResourceVersion value in the wrapped error and confirm it is numeric","Delete and recreate the pod to force a fresh numeric resourceVersion from the API server","Default an empty ResourceVersion to 0 before calling podForwardingEntry","Update client-go/skaffold if the cluster emits non-standard resourceVersions"],"exampleFix":"// before\nrv, err := strconv.Atoi(resourceVersion)\nif err != nil {\n    return nil, fmt.Errorf(\"converting resource version to integer: %w\", err)\n}\n// after\nif resourceVersion == \"\" {\n    resourceVersion = \"0\"\n}\nrv, err := strconv.Atoi(resourceVersion)\nif err != nil {\n    return nil, fmt.Errorf(\"converting resource version %q to integer: %w\", resourceVersion, err)\n}","handlingStrategy":"validation","validationCode":"rv, err := strconv.Atoi(resourceVersion)\nif err != nil {\n    return nil, fmt.Errorf(\"invalid resourceVersion %q: %w\", resourceVersion, err)\n}","typeGuard":"func isNumericResourceVersion(rv string) bool {\n    _, err := strconv.Atoi(rv)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["Default empty resourceVersion to 0 before conversion","Test port-forwarding against fake clientsets with realistic numeric resourceVersions","Include the offending value in the wrapped error message for faster triage"],"tags":["kubernetes","port-forward","strconv"],"backgroundTag":"resource-version-parse-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}