GoogleContainerTools/skaffold · error

portForward[%d] of config with name '%s' is empty, Please ch

Error message

portForward[%d] of config with name '%s' is empty, Please check if it has valid values

What it means

Schema defaults processing (Set) validates each portForward entry after applying defaults. A nil entry in the PortForward list is invalid configuration, so it errors identifying the index and config name, telling the user to supply valid portForward values.

Source

Thrown at pkg/skaffold/schema/defaults/defaults.go:111

		setDefaultCloudBuildMavenImage,
		setDefaultCloudBuildGradleImage,
		setDefaultCloudBuildKanikoImage,
		setDefaultCloudBuildPackImage,
		setDefaultCloudBuildKoImage,
	)

	if err := withClusterConfig(c,
		setDefaultClusterNamespace,
		setDefaultClusterTimeout,
		setDefaultClusterPullSecret,
		setDefaultClusterDockerConfigSecret,
	); err != nil {
		return err
	}

	for i, pf := range c.PortForward {
		if pf == nil {
			return fmt.Errorf("portForward[%d] of config with name '%s' is empty, Please check if it has valid values", i, c.Metadata.Name)
		}
		setDefaultLocalPort(pf)
		setDefaultAddress(pf)
	}

	setDefaultTestWorkspace(c)
	return nil
}

func setHelmDefaults(c *latest.SkaffoldConfig) error {
	if c.Deploy.LegacyHelmDeploy == nil {
		return nil
	}

	if c.Deploy.LegacyHelmDeploy.Concurrency == nil {
		defaultConcurrency := 1
		c.Deploy.LegacyHelmDeploy.Concurrency = &defaultConcurrency
	}

View on GitHub (pinned to a1189de023)

Solutions

  1. Open skaffold.yaml and fix or remove the empty portForward entry at the reported index
  2. Validate the merged result of profiles/overlays — an override may be nulling the entry
  3. Run `skaffold diagnose` to catch the malformed config before running
  4. Ensure programmatic config builders always append initialized &latest.PortForward{...} values

Example fix

# before: empty portForward entry
portForward:
  -
# after
portForward:
  - localPort: 8080
    port: 80
    resourceType: service
    resourceName: web
Defensive patterns

Strategy: validation

Validate before calling

for i, pf := range cfg.PortForward {
    if pf == nil { return fmt.Errorf("portForward[%d] is nil in skaffold.yaml", i) }
}
// run before passing config to defaults.Set

Try / catch

if err := defaults.Set(cfg); err != nil {
    var pe *fmt.Errorf
    if strings.Contains(err.Error(), "is empty") { return fmt.Errorf("malformed portForward entry: %v", err) }
    return err
}

Prevention

When it happens

Trigger: Calling Set (directly or via fix/withFallbackConfig/processEachConfig) on a config whose c.PortForward slice contains a nil element — i.e. an empty portForward item in skaffold.yaml or a programmatically built config with a nil pointer.

Common situations: A portForward entry in skaffold.yaml left empty/malformed (e.g. `- ` with no fields after merging config fragments or applying profiles), or generated configs where a portForward object failed to deserialize.

Related errors


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