{"record":{"id":"8f7c864d3341654d","repo":"GoogleContainerTools/skaffold","slug":"unmarshalling-global-skaffold-config-w","errorCode":null,"errorMessage":"unmarshalling global skaffold config: %w","messagePattern":"unmarshalling global skaffold config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/config/util.go","lineNumber":116,"sourceCode":"\t\t\treturn \"\", fmt.Errorf(\"retrieving home directory: %w\", err)\n\t\t}\n\t\tconfigFile = filepath.Join(home, defaultConfigDir, defaultConfigFile)\n\t}\n\treturn configFile, util.VerifyOrCreateFile(configFile)\n}\n\n// ReadConfigFileNoCache reads the given config yaml file and unmarshals the contents.\n// Only visible for testing, use ReadConfigFile instead.\nfunc ReadConfigFileNoCache(configFile string) (*GlobalConfig, error) {\n\tcontents, err := os.ReadFile(configFile)\n\tif err != nil {\n\t\tlog.Entry(context.TODO()).Warnf(\"Could not load global Skaffold defaults. Error encounter while reading file %q\", configFile)\n\t\treturn nil, fmt.Errorf(\"reading global config: %w\", err)\n\t}\n\tconfig := GlobalConfig{}\n\tif err := yaml.Unmarshal(contents, &config); err != nil {\n\t\tlog.Entry(context.TODO()).Warnf(\"Could not load global Skaffold defaults. Error encounter while unmarshalling the contents of file %q\", configFile)\n\t\treturn nil, fmt.Errorf(\"unmarshalling global skaffold config: %w\", err)\n\t}\n\treturn &config, nil\n}\n\n// GetConfigForCurrentKubectx returns the specific config to be modified based on the kubeContext.\n// Either returns the config corresponding to the provided or current context,\n// or the global config.\nfunc getConfigForCurrentKubectx(configFile string) (*ContextConfig, error) {\n\tconfigOnce.Do(func() {\n\t\tcfg, err := ReadConfigFile(configFile)\n\t\tif err != nil {\n\t\t\tconfigErr = err\n\t\t\treturn\n\t\t}\n\t\tkubeconfig, err := kubectx.CurrentConfig()\n\t\tif err != nil {\n\t\t\tconfigErr = err\n\t\t\treturn","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/config/util.go#L98-L134","documentation":"Fires in ReadConfigFileNoCache when the contents of the global skaffold config file (~/.skaffold/config) cannot be unmarshalled from YAML into the GlobalConfig struct — i.e. the file exists and is readable but is not valid skaffold config YAML (wrong shape, bad indentation, incompatible fields).","triggerScenarios":"Calling ReadConfigFileNoCache on a config.yaml containing malformed YAML (bad indentation, tabs, stray characters) or fields with types inconsistent with GlobalConfig.","commonSituations":"Hand-edited ~/.skaffold/config.yaml with syntax mistakes; partial/corrupt file after an interrupted write; concurrent skaffold processes racing on the same config file; schema drift after upgrading skaffold.","solutions":["Validate and fix YAML syntax, e.g. with `yamllint ~/.skaffold/config.yaml` or a YAML parser","Restore a known-good config (delete the file and let skaffold recreate it: rm ~/.skaffold/config.yaml)","Check the file wasn't truncated by an interrupted run; avoid concurrent skaffold processes writing it"],"exampleFix":"# before (broken)\ncollect_metrics: true\n  kubeContext: minikube\n# after\ncollect_metrics: true\nkubeContext: minikube","handlingStrategy":"validation","validationCode":"func validateGlobalConfigYAML(path string) error {\n  b, err := os.ReadFile(path)\n  if err != nil { return err }\n  var gc config.GlobalConfig\n  return yaml.Unmarshal(b, &gc)\n}\n// call before skaffold runs; on failure back up and delete the file","typeGuard":null,"tryCatchPattern":"cfg, err := config.ReadConfigFileNoCache(configFile)\nif err != nil && strings.Contains(err.Error(), \"unmarshalling\") {\n  os.Rename(configFile, configFile+\".bak\")\n  configFile, _ = config.ResolveConfigFile(\"\")\n  cfg, err = config.ReadConfigFileNoCache(configFile)\n}","preventionTips":["Validate YAML after hand-editing config.yaml","Don't run multiple skaffold processes writing the same config concurrently","Back up config.yaml before upgrading skaffold"],"tags":["yaml","config","parse-error"],"backgroundTag":"yaml-parse-error","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"}