GoogleContainerTools/skaffold · error
converting resource version to integer: %w
Error message
converting resource version to integer: %w
What it means
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.
Source
Thrown at pkg/skaffold/kubernetes/portforward/pod_forwarder.go:148
output.Yellow.Fprintf(p.output, "Forwarding container %s/%s to local port %d.\n", pod.Name, c.Name, entry.localPort)
}
if pe, ok := p.entryManager.forwardedResources.Load(entry.key()); ok {
prevEntry := pe.(*portForwardEntry)
// Check if this is a new generation of pod
if entry.resourceVersion > prevEntry.resourceVersion {
p.entryManager.Terminate(prevEntry)
}
}
p.entryManager.forwardPortForwardEntry(ctx, p.output, entry)
}
}
return nil
}
func (p *WatchingPodForwarder) podForwardingEntry(resourceVersion, containerName, portName, ownerReference string, resource latest.PortForwardResource) (*portForwardEntry, error) {
rv, err := strconv.Atoi(resourceVersion)
if err != nil {
return nil, fmt.Errorf("converting resource version to integer: %w", err)
}
entry := newPortForwardEntry(rv, resource, resource.Name, containerName, portName, ownerReference, 0, true)
// If we have, return the current entry
oe, ok := p.entryManager.forwardedResources.Load(entry.key())
if ok {
oldEntry := oe.(*portForwardEntry)
entry.localPort = oldEntry.localPort
return entry, nil
}
// retrieve an open port on the host
entry.localPort = retrieveAvailablePort(resource.Address, resource.Port.IntVal, &p.entryManager.forwardedPorts)
return entry, nil
}
View on GitHub (pinned to a1189de023)
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
Example fix
// before
rv, err := strconv.Atoi(resourceVersion)
if err != nil {
return nil, fmt.Errorf("converting resource version to integer: %w", err)
}
// after
if resourceVersion == "" {
resourceVersion = "0"
}
rv, err := strconv.Atoi(resourceVersion)
if err != nil {
return nil, fmt.Errorf("converting resource version %q to integer: %w", resourceVersion, err)
} Defensive patterns
Strategy: validation
Validate before calling
rv, err := strconv.Atoi(resourceVersion)
if err != nil {
return nil, fmt.Errorf("invalid resourceVersion %q: %w", resourceVersion, err)
} Type guard
func isNumericResourceVersion(rv string) bool {
_, err := strconv.Atoi(rv)
return err == nil
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- could not fetch deployed resource namespace. This might caus
- could not fetch deployed resource namespace. This might caus
- no pods match service %s/%s
- service %q does not expose port %s
- getting pod forwarding entry: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/cae428babc5fd5c0.
Report an issue: GitHub.