GoogleContainerTools/skaffold · error

%s is an invalid api version

Error message

%s is an invalid api version

What it means

Parse converts a Skaffold API version string like skaffold/v4beta7 into a semver via the regex ^skaffold/v(\d)(?:(alpha|beta)([1-9]?[0-9]))?$. If the string doesn't match the expected shape, Parse returns this invalid-api-version error. Used when loading skaffold.yaml apiVersion fields and during config upgrades.

Source

Thrown at pkg/skaffold/apiversion/apiversion.go:32

limitations under the License.
*/

package apiversion

import (
	"fmt"
	"regexp"

	"github.com/blang/semver"
)

var re = regexp.MustCompile(`^skaffold/v(\d)(?:(alpha|beta)([1-9]?[0-9]))?$`)

// Parse parses a string into a semver.Version.
func Parse(v string) (semver.Version, error) {
	res := re.FindStringSubmatch(v)
	if res == nil {
		return semver.Version{}, fmt.Errorf("%s is an invalid api version", v)
	}
	if res[2] == "" || res[3] == "" {
		return semver.Parse(fmt.Sprintf("%s.0.0", res[1]))
	}
	return semver.Parse(fmt.Sprintf("%s.0.0-%s.%s", res[1], res[2], res[3]))
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Set apiVersion to a valid schema like skaffold/v4beta13 (single major digit, alpha/beta + 1-2 digit number)
  2. Run `skaffold fix` to migrate an older/invalid version to the current schema
  3. Check exact spelling: lowercase, format skaffold/vN(alpha|beta)N with no spaces

Example fix

// before
apiVersion: skaffold/v14beta1
kind: Config
// after
apiVersion: skaffold/v4beta13
kind: Config
Defensive patterns

Strategy: validation

Validate before calling

const re = /^skaffold\/v(\d)(?:(alpha|beta)([1-9]?[0-9]))?$/;
const v = doc.apiVersion;
if (!re.test(v)) throw new Error(`${v} is an invalid api version`);

Try / catch

try {
  sv, err := apiversion.Parse(cfg.APIVersion)
  if err != nil { return fmt.Errorf("skaffold.yaml apiVersion %q unsupported: %w", cfg.APIVersion, err) }
} ...

Prevention

When it happens

Trigger: skaffold.yaml declares apiVersion with an unsupported form: skaffold/v2 (multi-digit), skaffold/v4gamma1, skaffold/v10, missing the skaffold/ prefix, or the UpgradeTo pipeline parsing an arbitrary string.

Common situations: Editing skaffold.yaml by hand with a made-up version; copying an example from a different tool; skaffold/v2alpha4 style (two digits in major) which the single-digit regex rejects; accidentally deleting the version line leaving a corrupt value.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/9d507c9445a45d29. Report an issue: GitHub.