GoogleContainerTools/skaffold · error
getting pod forwarding entry: %w
Error message
getting pod forwarding entry: %w
What it means
WatchingPodForwarder.portForwardPod builds a PortForwardResource for each container port and calls podForwardingEntry to create or reuse a forwarding entry. The resource version string from the pod is converted internally; if that fails or the entry cannot be built, the error is wrapped as "getting pod forwarding entry". It indicates the pod's forwarding entry could not be constructed, aborting port-forward setup for that container.
Source
Thrown at pkg/skaffold/kubernetes/portforward/pod_forwarder.go:127
p.podWatcher.Deregister(p.events)
}
func (p *WatchingPodForwarder) portForwardPod(ctx context.Context, pod *v1.Pod) error {
ownerReference := topLevelOwnerKey(ctx, pod, p.kubeContext, pod.Kind)
for _, c := range pod.Spec.Containers {
for _, port := range p.containerPorts(pod, c) {
// get current entry for this container
resource := latest.PortForwardResource{
Type: constants.Pod,
Name: pod.Name,
Namespace: pod.Namespace,
Port: schemautil.FromInt(int(port.ContainerPort)),
Address: constants.DefaultPortForwardAddress,
}
entry, err := p.podForwardingEntry(pod.ResourceVersion, c.Name, port.Name, ownerReference, resource)
if err != nil {
return fmt.Errorf("getting pod forwarding entry: %w", err)
}
if entry.resource.Port.IntVal != entry.localPort {
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) {View on GitHub (pinned to a1189de023)
Solutions
- Inspect the wrapped inner error to see whether strconv.Atoi failed on the resource version and log the pod's actual ResourceVersion value
- Restart the affected pod so the API server issues a fresh numeric resourceVersion
- Upgrade or align client-go / kubectl versions with the cluster's API server
- Re-run skaffold dev; transient informer cache staleness often resolves on the next watch event
Example fix
// before (diagnostic)
entry, err := p.podForwardingEntry(pod.ResourceVersion, c.Name, port.Name, ownerReference, resource)
// after (guard against empty/non-numeric resourceVersion)
rv := pod.ResourceVersion
if rv == "" {
rv = "0"
}
entry, err := p.podForwardingEntry(rv, c.Name, port.Name, ownerReference, resource) Defensive patterns
Strategy: try-catch
Validate before calling
if pod.ResourceVersion == "" {
return fmt.Errorf("pod %s has empty resourceVersion; recreate pod", pod.Name)
}
if _, err := strconv.Atoi(pod.ResourceVersion); err != nil {
return fmt.Errorf("pod %s resourceVersion %q not numeric", pod.Name, pod.ResourceVersion)
} Type guard
func hasNumericResourceVersion(pod metav1.Object) bool {
_, err := strconv.Atoi(pod.GetResourceVersion())
return err == nil
} Try / catch
entry, err := p.podForwardingEntry(pod.ResourceVersion, c.Name, port.Name, ownerReference, resource)
if err != nil {
log.Warnf("skipping port-forward for %s/%s: %v", pod.Name, c.Name, err)
return nil // or retry on next watch event
} Prevention
- Log pod.ResourceVersion before forwarding so failures are diagnosable
- Keep client-go and cluster versions aligned
- Recreate pods whose metadata looks incomplete rather than retrying blindly
When it happens
Trigger: podForwardingEntry returns an error while portForwardPod iterates container ports of a pod being watched — typically strconv.Atoi failing on a malformed pod.ResourceVersion, or an entry-manager failure during Load/Store of the forwarded resource.
Common situations: Deploying to clusters or mock/informer setups where pod ResourceVersion is non-numeric or empty; corrupted pod state from an API-server or client-go version mismatch; races where a pod object is a partial/deleted stub when the forwarder processes it.
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
- converting resource version to integer: %w
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/d5414d8138b275b8.
Report an issue: GitHub.