{"record":{"id":"d7714511540d49bc","repo":"GoogleContainerTools/skaffold","slug":"missing-apiversion","errorCode":null,"errorMessage":"missing apiVersion","messagePattern":"missing apiVersion","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/schema/versions.go","lineNumber":259,"sourceCode":"\treturn parseConfig(buf, factories)\n}\n\n// ParseConfigAndUpgrade reads a configuration file and upgrades it to a given version.\nfunc ParseConfigAndUpgrade(filename string) ([]util.VersionedConfig, error) {\n\tconfigs, err := ParseConfig(filename)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn UpgradeTo(configs, latest.Version)\n}\n\n// configFactoryFromAPIVersion checks that all configs in the input stream have the same API version, and returns a function to create a config with that API version.\nfunc configFactoryFromAPIVersion(buf []byte) ([]func() util.VersionedConfig, error) {\n\t// This is to quickly check that it's possibly a skaffold.yaml,\n\t// without parsing the whole file.\n\tif !bytes.Contains(buf, []byte(\"apiVersion\")) {\n\t\treturn nil, errors.New(\"missing apiVersion\")\n\t}\n\n\tvar factories []func() util.VersionedConfig\n\tb := bytes.NewReader(buf)\n\tdecoder := yaml.NewDecoder(b)\n\tfor {\n\t\tvar v APIVersion\n\t\terr := decoder.Decode(&v)\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"parsing api version: %w\", err)\n\t\t}\n\t\tfactory, present := AllVersions.Find(v.Version)\n\t\tif !present {\n\t\t\treturn nil, sErrors.ConfigUnknownAPIVersionErr(v.Version)\n\t\t}","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/schema/versions.go#L241-L277","documentation":"Skaffold's config parser needs to determine the schema version (apiVersion) to select the matching config factory. As a fast pre-parse check, configFactoryFromAPIVersion scans the raw bytes for the string \"apiVersion\"; if absent, it fails immediately with \"missing apiVersion\" instead of decoding YAML.","triggerScenarios":"Passing a YAML file that is not a skaffold config (no apiVersion key) to skaffold commands or the config-parse API; passing JSON that lacks apiVersion; piping empty or truncated files via `-f -`; pointing -f at a README, values.yaml, or Kubernetes manifest without apiVersion.","commonSituations":"Typos like `api-version:` or `apiVersion :`; accidentally renaming apiVersion key; using an example snippet without the header; feeding a kustomization.yaml (no apiVersion in old versions) to skaffold.","solutions":["Add `apiVersion: skaffold/<version>` (e.g. skaffold/v4beta7) and a `kind: Config` at the top of your skaffold.yaml.","Confirm the file passed via -f/--filename is actually a skaffold config.","Run `skaffold init` to generate a correctly structured skaffold.yaml.","Fix key spelling/indentation so `apiVersion` appears as a top-level YAML key."],"exampleFix":"// before\nkind: Config\ndeploy:\n  kubectl: {}\n// after\napiVersion: skaffold/v4beta7\nkind: Config\ndeploy:\n  kubectl: {}","handlingStrategy":"validation","validationCode":"const doc = yaml.parse(fs.readFileSync(file, 'utf8'));\nif (!doc || typeof doc !== 'object' || !('apiVersion' in doc)) {\n  throw new Error(`${file} is not a skaffold config: missing apiVersion`);\n}","typeGuard":"function isSkaffoldConfig(o) {\n  return typeof o === 'object' && o !== null && typeof o.apiVersion === 'string' && o.apiVersion.startsWith('skaffold/') && o.kind === 'Config';\n}","tryCatchPattern":"try {\n  execSync('skaffold config', { stdio: 'pipe' });\n} catch (e) {\n  if (String(e).includes('missing apiVersion')) console.error('Add apiVersion: skaffold/<ver> to skaffold.yaml');\n}","preventionTips":["Start every skaffold.yaml with apiVersion + kind: Config","Never point -f at non-skaffold YAML files","Regenerate configs with `skaffold init` for new projects"],"tags":["skaffold","yaml","schema","config-validation"],"backgroundTag":"missing-api-version","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"}