{"record":{"id":"40fd0f9679d30a1b","repo":"GoogleContainerTools/skaffold","slug":"portforward-d-of-config-with-name-s-is-empty","errorCode":null,"errorMessage":"portForward[%d] of config with name '%s' is empty, Please check if it has valid values","messagePattern":"portForward\\[(.+?)\\] of config with name '(.+?)' is empty, Please check if it has valid values","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/schema/defaults/defaults.go","lineNumber":111,"sourceCode":"\t\tsetDefaultCloudBuildMavenImage,\n\t\tsetDefaultCloudBuildGradleImage,\n\t\tsetDefaultCloudBuildKanikoImage,\n\t\tsetDefaultCloudBuildPackImage,\n\t\tsetDefaultCloudBuildKoImage,\n\t)\n\n\tif err := withClusterConfig(c,\n\t\tsetDefaultClusterNamespace,\n\t\tsetDefaultClusterTimeout,\n\t\tsetDefaultClusterPullSecret,\n\t\tsetDefaultClusterDockerConfigSecret,\n\t); err != nil {\n\t\treturn err\n\t}\n\n\tfor i, pf := range c.PortForward {\n\t\tif pf == nil {\n\t\t\treturn fmt.Errorf(\"portForward[%d] of config with name '%s' is empty, Please check if it has valid values\", i, c.Metadata.Name)\n\t\t}\n\t\tsetDefaultLocalPort(pf)\n\t\tsetDefaultAddress(pf)\n\t}\n\n\tsetDefaultTestWorkspace(c)\n\treturn nil\n}\n\nfunc setHelmDefaults(c *latest.SkaffoldConfig) error {\n\tif c.Deploy.LegacyHelmDeploy == nil {\n\t\treturn nil\n\t}\n\n\tif c.Deploy.LegacyHelmDeploy.Concurrency == nil {\n\t\tdefaultConcurrency := 1\n\t\tc.Deploy.LegacyHelmDeploy.Concurrency = &defaultConcurrency\n\t}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/schema/defaults/defaults.go#L93-L129","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open skaffold.yaml and fix or remove the empty portForward entry at the reported index","Validate the merged result of profiles/overlays — an override may be nulling the entry","Run `skaffold diagnose` to catch the malformed config before running","Ensure programmatic config builders always append initialized &latest.PortForward{...} values"],"exampleFix":"# before: empty portForward entry\nportForward:\n  -\n# after\nportForward:\n  - localPort: 8080\n    port: 80\n    resourceType: service\n    resourceName: web","handlingStrategy":"validation","validationCode":"for i, pf := range cfg.PortForward {\n    if pf == nil { return fmt.Errorf(\"portForward[%d] is nil in skaffold.yaml\", i) }\n}\n// run before passing config to defaults.Set","typeGuard":null,"tryCatchPattern":"if err := defaults.Set(cfg); err != nil {\n    var pe *fmt.Errorf\n    if strings.Contains(err.Error(), \"is empty\") { return fmt.Errorf(\"malformed portForward entry: %v\", err) }\n    return err\n}","preventionTips":["Lint skaffold.yaml (skaffold diagnose / schema validation) after every edit","Check profile merges and overlays don't null out portForward items","Never append nil pointers when building configs programmatically"],"tags":["skaffold","schema","port-forward","config-validation"],"backgroundTag":"empty-port-forward-config","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"}