GoogleContainerTools/skaffold · critical
parsing api version: %w
Error message
parsing api version: %w
What it means
ParseConfig streams the YAML documents to discover each document's apiVersion. If the YAML decode of a document fails (not EOF), this wrapped error is returned. Note this is about decode failure — an unknown but successfully parsed version produces ConfigUnknownAPIVersionErr instead.
Source
Thrown at pkg/skaffold/schema/versions.go:272
// 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.
func configFactoryFromAPIVersion(buf []byte) ([]func() util.VersionedConfig, error) {
// This is to quickly check that it's possibly a skaffold.yaml,
// without parsing the whole file.
if !bytes.Contains(buf, []byte("apiVersion")) {
return nil, errors.New("missing apiVersion")
}
var factories []func() util.VersionedConfig
b := bytes.NewReader(buf)
decoder := yaml.NewDecoder(b)
for {
var v APIVersion
err := decoder.Decode(&v)
if err == io.EOF {
break
}
if err != nil {
return nil, fmt.Errorf("parsing api version: %w", err)
}
factory, present := AllVersions.Find(v.Version)
if !present {
return nil, sErrors.ConfigUnknownAPIVersionErr(v.Version)
}
factories = append(factories, factory)
}
return factories, nil
}
// removeYamlAnchors removes all top-level keys starting with `.` from the input stream so they can be used as YAML anchors
func removeYamlAnchors(buf []byte) ([]byte, error) {
in := bytes.NewReader(buf)
var out bytes.Buffer
decoder := yaml.NewDecoder(in)
decoder.KnownFields(true)
encoder := yaml.NewEncoder(&out)View on GitHub (pinned to a1189de023)
Solutions
- Run a YAML linter (yamllint) on skaffold.yaml to find syntax errors
- Fix indentation — use spaces, never tabs
- Check the wrapped cause (%w) for the exact line/parse problem
- Restore the file from version control if it was truncated
Example fix
# before (tab indentation breaks YAML) apiVersion: skaffold/v4beta7 metadata: name: app # after apiVersion: skaffold/v4beta7 metadata: name: app
Defensive patterns
Strategy: validation
Validate before calling
var raw map[string]interface{}
if err := yaml.Unmarshal(data, &raw); err != nil {
return fmt.Errorf("skaffold.yaml is not valid YAML: %w", err)
}
if _, ok := raw["apiVersion"]; !ok {
return errors.New("skaffold.yaml missing apiVersion")
} Try / catch
_, err := schema.ParseConfig(cfgPath)
if err != nil {
if strings.Contains(err.Error(), "parsing api version") {
// surface a YAML-syntax hint to the user and stop
}
return err
} Prevention
- Lint YAML (yamllint) in CI before invoking skaffold
- Use spaces, never tabs, for indentation
- Pin the expected apiVersion and check it before parsing
When it happens
Trigger: Calling ParseConfig on a file containing malformed YAML (bad indentation, invalid syntax, wrong types) so the version-decoding pass errors before finding the apiVersion.
Common situations: Hand-edited skaffold.yaml with tab indentation or broken indentation; pasting YAML with smart quotes; truncated file from a failed write; multi-doc file with a corrupt segment.
Related errors
- unable to re-marshal YAML without dotted keys: %w
- unable to parse YAML: %w
- read skaffold config: %w
- `apply` requires at least one manifest argument
- `exec` requires exactly one action to execute
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/5d9ac728c53046f3.
Report an issue: GitHub.