lima-vm/lima · error

failed to validate the instance YAML after filling defaults

Error message

failed to validate the instance YAML after filling defaults: %w

What it means

After successfully building the driver, createConfiguredDriver re-validates the instance's fully-defaulted YAML with limayaml.Validate(inst.Config, true). If the configuration is invalid even after defaults are filled in (contradictory or out-of-range fields), the snapshot operation aborts with this message. It guards against running snapshot operations on configs that the driver layer would silently mishandle.

Solutions

  1. Read the wrapped validation detail; it names the exact offending field — fix that field in ~/.lima/<instance>/lima.yaml
  2. Run limactl validate (or limayaml.Load+Validate locally) on the instance YAML to see all validation errors at once
  3. Restore the YAML to a known-good state: re-edit, or recreate the instance and re-apply your customizations
  4. If it broke after a Lima upgrade, consult release notes for removed/renamed fields and migrate the config accordingly

Example fix

// before (instance lima.yaml)
cpus: -2
// after
// lima.yaml
cpus: 4
Defensive patterns

Strategy: validation

Validate before calling

if err := limayaml.Validate(inst.Config, true); err != nil {
	return fmt.Errorf("instance YAML invalid, fix before snapshot ops: %w", err)
}

Type guard

func validInstanceConfig(inst *limatype.Instance) bool {
	return inst != nil && inst.Config != nil && limayaml.Validate(inst.Config, true) == nil
}

Prevention

When it happens

Trigger: Any snapshot operation (Del/Save/Load/List, i.e. limactl snapshot save/apply/delete/list) on an instance whose stored lima.yaml fails schema/range validation after defaults: e.g. invalid vmType value, conflicting cpu/memory settings, deprecated fields that no longer validate, or a hand-edited YAML with a bad enum value that the driver lookup tolerated but validation rejects.

Common situations: Manual edits to ~/.lima/<instance>/lima.yaml (typo'd enum, negative CPU count, invalid architecture); configs written by an older Lima version that no longer pass the stricter validator after upgrade; cloner/external tooling that mutated the instance YAML; merging templates with incompatible fields.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/f6a776460b0a9835. Report an issue: GitHub.

Appendix: source

Thrown at pkg/snapshot/snapshot.go:55

	}
	return limaDriver.ApplySnapshot(ctx, tag)
}

func List(ctx context.Context, inst *limatype.Instance) (string, error) {
	limaDriver, err := createConfiguredDriver(ctx, inst)
	if err != nil {
		return "", fmt.Errorf("failed to create driver instance: %w", err)
	}
	return limaDriver.ListSnapshots(ctx)
}

func createConfiguredDriver(ctx context.Context, inst *limatype.Instance) (*driver.ConfiguredDriver, error) {
	limaDriver, err := driverutil.CreateConfiguredDriver(ctx, inst, 0)
	if err != nil {
		return nil, fmt.Errorf("failed to create driver instance: %w", err)
	}
	if err := limayaml.Validate(inst.Config, true); err != nil {
		return nil, fmt.Errorf("failed to validate the instance YAML after filling defaults: %w", err)
	}
	return limaDriver, nil
}

View on GitHub (pinned to dd909d0973)