GoogleContainerTools/skaffold · error
merging context-specific and global config: %w
Error message
merging context-specific and global config: %w
What it means
getConfigForKubeContextWithGlobalDefaults starts from the context-specific config and, when cfg.Global is set, merges global defaults into it via mergo (WithAppendSlice). This error means the mergo merge itself failed — rare, but it makes the resulting per-context config unreliable so the library aborts.
Source
Thrown at pkg/skaffold/config/util.go:164
}
return cfg.Global, nil
}
var mergedConfig ContextConfig
for _, contextCfg := range cfg.ContextConfigs {
if util.RegexEqual(contextCfg.Kubecontext, kubeContext) {
log.Entry(context.TODO()).Debugf("found config for context %q", kubeContext)
mergedConfig = *contextCfg
}
}
// in case there was no config for this kubeContext in cfg.ContextConfigs
mergedConfig.Kubecontext = kubeContext
if cfg.Global != nil {
// if values are unset for the current context, retrieve
// the global config and use its values as a fallback.
if err := mergo.Merge(&mergedConfig, cfg.Global, mergo.WithAppendSlice); err != nil {
return nil, fmt.Errorf("merging context-specific and global config: %w", err)
}
}
return &mergedConfig, nil
}
func GetDefaultRepo(configFile string, cliValue *string) (string, error) {
// CLI flag takes precedence.
if cliValue != nil {
return *cliValue, nil
}
cfg, err := GetConfigForCurrentKubectx(configFile)
if err != nil {
return "", err
}
if cfg.DefaultRepo != "" {
log.Entry(context.TODO()).Infof("Using default-repo=%s from config", cfg.DefaultRepo)
}
return cfg.DefaultRepo, nilView on GitHub (pinned to a1189de023)
Solutions
- Inspect the per-kubecontext entries in ~/.skaffold/config.yaml for fields with unexpected types and fix them
- Remove the suspect kubecontext section and let skaffold regenerate defaults
- Align file format with your skaffold version (upgrade or downgrade so schemas match)
Defensive patterns
Strategy: try-catch
Validate before calling
func validateGlobalConfigShape(path string) error {
cfg, err := config.ReadConfigFileNoCache(path)
if err != nil { return err }
for kctx, kc := range cfg.Kubecontexts {
if kc == nil { return fmt.Errorf("kubecontext %q is null", kctx) }
}
return nil
} Try / catch
cfg, err := config.GetConfigForCurrentKubectx(configFile)
if err != nil && strings.Contains(err.Error(), "merging context-specific and global config") {
log.Warn("falling back to context config without global defaults")
cfg, err = readContextConfigOnly(configFile)
} Prevention
- Don't hand-edit typed fields in the kubecontexts section
- Keep skaffold version consistent with the config file schema
- Regenerate per-context entries instead of patching them manually
When it happens
Trigger: Calling getConfigForKubeContextWithGlobalDefaults (via GetConfigForCurrentKubectx) where the context-specific GlobalConfig contains fields mergo cannot merge with the global config (e.g. incompatible slice/map types after schema drift or a hand-edited file).
Common situations: Config files written by a different skaffold version with a changed GlobalConfig schema; manually edited config.yaml with wrong field types for a kubecontext entry.
Related errors
- bucket name is empty
- INSPECT_PROFILE_NOT_FOUND_ERR
- cannot resolve active Kubernetes context - multiple contexts
- CONFIG_BAD_FILTER_ERR
- CONFIG_ZERO_FOUND_ERR
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/1f8ccf8236328eb9.
Report an issue: GitHub.