GoogleContainerTools/skaffold · error

%s is not a valid resource type for port forwarding

Error message

%s is not a valid resource type for port forwarding

What it means

validatePortForwardResources checks every portForward entry's resourceType against the allowed set: container, pod, deployment, service, replicaset, replicationcontroller, statefulset, daemonset, cronjob, job (case-insensitive). Any other type is rejected because Skaffold cannot resolve it into a Kubernetes object to port-forward.

Source

Thrown at pkg/skaffold/schema/validation/validation.go:591

func validatePortForwardResources(cfg *parser.SkaffoldConfigEntry, pfrs []*latest.PortForwardResource) []ErrorWithLocation {
	var errs []ErrorWithLocation
	validResourceTypes := map[string]struct{}{
		"container":             {},
		"pod":                   {},
		"deployment":            {},
		"service":               {},
		"replicaset":            {},
		"replicationcontroller": {},
		"statefulset":           {},
		"daemonset":             {},
		"cronjob":               {},
		"job":                   {},
	}
	for i, pfr := range pfrs {
		resourceType := strings.ToLower(string(pfr.Type))
		if _, ok := validResourceTypes[resourceType]; !ok {
			errs = append(errs, ErrorWithLocation{
				Error:    fmt.Errorf("%s is not a valid resource type for port forwarding", pfr.Type),
				Location: cfg.YAMLInfos.Locate(pfrs[i]),
			})
		}
	}
	return errs
}

// validateJibPluginTypes makes sure that jib type is one of `maven`, or `gradle` if set.
func validateJibPluginTypes(cfg *parser.SkaffoldConfigEntry, artifacts []*latest.Artifact) (cfgErrs []ErrorWithLocation) {
	for i, a := range artifacts {
		if a.JibArtifact == nil || a.JibArtifact.Type == "" {
			continue
		}
		t := strings.ToLower(a.JibArtifact.Type)
		if t == "maven" || t == "gradle" {
			continue
		}
		cfgErrs = append(cfgErrs, ErrorWithLocation{

View on GitHub (pinned to a1189de023)

Solutions

  1. Change resourceType to a supported singular kind: pod, deployment, service, replicaset, replicationcontroller, statefulset, daemonset, cronjob, job, or container
  2. Replace short/plural names ('svc', 'pods') with the full singular kind
  3. Remove the entry if the resource kind is unsupported (e.g. ingress) and port-forward manually with kubectl

Example fix

// before
portForward:
  - resourceType: svc
    resourceName: api
    port: 8080
// after
portForward:
  - resourceType: service
    resourceName: api
    port: 8080
Defensive patterns

Strategy: validation

Validate before calling

// Go: allowed port-forward resource types
var validResourceTypes = map[string]bool{
	"container": true, "pod": true, "deployment": true, "service": true,
	"replicaset": true, "replicationcontroller": true, "statefulset": true,
	"daemonset": true, "cronjob": true, "job": true,
}
func validPortForwardType(t string) bool { return validResourceTypes[strings.ToLower(t)] }

Try / catch

if !validPortForwardType(resourceType) {
	return fmt.Errorf("%q is not a valid port-forward resource type", resourceType)
}

Prevention

When it happens

Trigger: skaffold.yaml has a portForward resource whose type is misspelled or unsupported (e.g. 'pods', 'svc', 'ingress', 'StatefulSet ' with a trailing space isn't the issue since it's lowered — but 'ingress' is simply not in the set).

Common situations: Using Kubernetes short names ('svc', 'deploy'), plural forms ('pods'), or resource types Skaffold doesn't support like ingress or custom CRDs.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/539435b7914bd4fe. Report an issue: GitHub.