nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pulumi/actions
Pull request #63 (2021-02-08 21:19:07)

fix: `commentOnPr` always true


Patch:
diff --git a/.eslintrc.json b/.eslintrc.json
index 55fbf15..f9feca9 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -41,7 +41,8 @@
       "rules": {
         "@typescript-eslint/ban-ts-comment": "off",
         "@typescript-eslint/no-explicit-any": "off",
-        "@typescript-eslint/no-unused-vars": "off"
+        "@typescript-eslint/no-unused-vars": "off",
+        "@typescript-eslint/no-var-requires": "off"
       }
     }
   ]
diff --git a/src/config.ts b/src/config.ts
index 6aabbac..eb83c6f 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -28,6 +28,6 @@ export async function makeConfig(): Promise<Config> {
     workDir: getInput('work-dir') || './',
     cloudUrl: getInput('cloud-url'),
     githubToken: getInput('github-token'),
-    commentOnPr: getInput('comment-on-pr') ? true : false,
+    commentOnPr: getInput('comment-on-pr') === "true" ? true : false,
   });
 }


Test patch:
diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts
new file mode 100644
index 0000000..956bd76
--- /dev/null
+++ b/src/__tests__/config.test.ts
@@ -0,0 +1,75 @@
+const defaultConfig: Record<string, string> = {
+  command: 'up',
+  'stack-name': 'dev',
+  'work-dir': './',
+  'cloud-url': 'file://~',
+  'github-token': 'n/a',
+};
+
+describe('config.ts', () => {
+  beforeEach(() => {
+    jest.resetModules();
+  });
+  it('should validate a configuration', async () => {
+    const config = {
+      ...defaultConfig,
+      'comment-on-pr': 'false',
+    };
+    jest.mock('@actions/core', () => ({
+      getInput: jest.fn((name: string) => {
+        return config[name];
+      }),
+    }));
+
+    const { makeConfig } = require('../config');
+
+    const c = await makeConfig();
+    expect(c).toBeTruthy();
+    expect(c).toEqual({
+      command: 'up',
+      stackName: 'dev',
+      cloudUrl: 'file://~',
+      githubToken: 'n/a',
+      commentOnPr: false,
+      workDir: './',
+    });
+  });
+  it('should fail if configuration are invalid', async () => {
+    const config: Record<string, string> = {
+      command: 'sideways',
+    };
+    jest.mock('@actions/core', () => ({
+      getInput: jest.fn((name: string) => {
+        return config[name];
+      }),
+    }));
+
+    const { makeConfig } = require('../config');
+
+    await expect(makeConfig()).rejects.toThrow();
+  });
+  it('should validate a configuration with commentOnPr eq true', async () => {
+    const config = {
+      ...defaultConfig,
+      'comment-on-pr': 'true',
+    };
+    jest.mock('@actions/core', () => ({
+      getInput: jest.fn((name: string) => {
+        return config[name];
+      }),
+    }));
+
+    const { makeConfig } = require('../config');
+
+    const c = await makeConfig();
+    expect(c).toBeTruthy();
+    expect(c).toEqual({
+      command: 'up',
+      stackName: 'dev',
+      cloudUrl: 'file://~',
+      githubToken: 'n/a',
+      commentOnPr: true,
+      workDir: './',
+    });
+  });
+});
Repository: lima-vm/lima
Pull request #894 (2022-06-11 09:56:48)

Only use cpuType=host for OS with accel available
This should be matching the qemu getAccel() values

Specifically, no acceleration on FreeBSD right now

Issue #892


Patch:
diff --git a/pkg/limayaml/defaults.go b/pkg/limayaml/defaults.go
index 128360ba..ee500c6e 100644
--- a/pkg/limayaml/defaults.go
+++ b/pkg/limayaml/defaults.go
@@ -105,7 +105,7 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
 		RISCV64: "rv64", // FIXME: what is the right choice for riscv64?
 	}
 	for arch := range cpuType {
-		if IsNativeArch(arch) {
+		if IsNativeArch(arch) && IsAccelOS() {
 			cpuType[arch] = "host"
 		}
 	}
@@ -612,6 +612,16 @@ func ResolveArch(s *string) Arch {
 	return *s
 }
 
+func IsAccelOS() bool {
+	switch runtime.GOOS {
+	case "darwin", "linux", "netbsd", "windows":
+		// Accelerator
+		return true
+	}
+	// Using TCG
+	return false
+}
+
 func IsNativeArch(arch Arch) bool {
 	nativeX8664 := arch == X8664 && runtime.GOARCH == "amd64"
 	nativeAARCH64 := arch == AARCH64 && runtime.GOARCH == "arm64"


Test patch:
diff --git a/pkg/limayaml/defaults_test.go b/pkg/limayaml/defaults_test.go
index 16794cdd..0c212a71 100644
--- a/pkg/limayaml/defaults_test.go
+++ b/pkg/limayaml/defaults_test.go
@@ -83,7 +83,9 @@ func TestFillDefault(t *testing.T) {
 			RemoveDefaults: pointer.Bool(false),
 		},
 	}
-	builtin.CPUType[arch] = "host"
+	if IsAccelOS() {
+		builtin.CPUType[arch] = "host"
+	}
 
 	defaultPortForward := PortForward{
 		GuestIP:        api.IPv4loopback1,
Repository: lima-vm/lima
Pull request #900 (2022-06-12 16:49:45)

Not all OS with -accel has -cpu host option
Instead use -cpu max, for everything available.

Affects NetBSD (NVMM) and Windows (WHPX)

Follow-up from #894


Patch:
diff --git a/pkg/limayaml/defaults.go b/pkg/limayaml/defaults.go
index ee500c6e..6c839e20 100644
--- a/pkg/limayaml/defaults.go
+++ b/pkg/limayaml/defaults.go
@@ -106,7 +106,9 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
 	}
 	for arch := range cpuType {
 		if IsNativeArch(arch) && IsAccelOS() {
-			cpuType[arch] = "host"
+			if HasHostCPU() {
+				cpuType[arch] = "host"
+			}
 		}
 	}
 	for k, v := range d.CPUType {
@@ -622,6 +624,17 @@ func IsAccelOS() bool {
 	return false
 }
 
+func HasHostCPU() bool {
+	switch runtime.GOOS {
+	case "darwin", "linux":
+		return true
+	case "netbsd", "windows":
+		return false
+	}
+	// Not reached
+	return false
+}
+
 func IsNativeArch(arch Arch) bool {
 	nativeX8664 := arch == X8664 && runtime.GOARCH == "amd64"
 	nativeAARCH64 := arch == AARCH64 && runtime.GOARCH == "arm64"


Test patch:
diff --git a/pkg/limayaml/defaults_test.go b/pkg/limayaml/defaults_test.go
index 0c212a71..eea03dc9 100644
--- a/pkg/limayaml/defaults_test.go
+++ b/pkg/limayaml/defaults_test.go
@@ -84,7 +84,9 @@ func TestFillDefault(t *testing.T) {
 		},
 	}
 	if IsAccelOS() {
-		builtin.CPUType[arch] = "host"
+		if HasHostCPU() {
+			builtin.CPUType[arch] = "host"
+		}
 	}
 
 	defaultPortForward := PortForward{
Repository: lima-vm/lima
Pull request #931 (2022-06-29 16:26:04)

whpx: Don't use -cpu max, add kernel-irqchip=off
Doesn't work now, after adding 017a56ca10f0a867c73d2b06547302787ffddabc

Also needs to avoid falling back on tcg

----

Tested on Windows 10 (Pro), x64 (Intel)

Using Alpine Linux, and Alpine-Lima


Patch:
diff --git a/pkg/limayaml/defaults.go b/pkg/limayaml/defaults.go
index c74aef56..a270b91a 100644
--- a/pkg/limayaml/defaults.go
+++ b/pkg/limayaml/defaults.go
@@ -108,7 +108,7 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
 		if IsNativeArch(arch) && IsAccelOS() {
 			if HasHostCPU() {
 				cpuType[arch] = "host"
-			} else {
+			} else if HasMaxCPU() {
 				cpuType[arch] = "max"
 			}
 		}
@@ -637,6 +637,11 @@ func HasHostCPU() bool {
 	return false
 }
 
+func HasMaxCPU() bool {
+	// WHPX: Unexpected VP exit code 4
+	return runtime.GOOS != "windows"
+}
+
 func IsNativeArch(arch Arch) bool {
 	nativeX8664 := arch == X8664 && runtime.GOARCH == "amd64"
 	nativeAARCH64 := arch == AARCH64 && runtime.GOARCH == "arm64"
diff --git a/pkg/qemu/qemu.go b/pkg/qemu/qemu.go
index 08fd9571..83262f26 100644
--- a/pkg/qemu/qemu.go
+++ b/pkg/qemu/qemu.go
@@ -369,7 +369,7 @@ func Cmdline(cfg Config) (string, []string, error) {
 	args = appendArgsIfNoConflict(args, "-cpu", cpu)
 	switch *y.Arch {
 	case limayaml.X8664:
-		if strings.HasPrefix(cpu, "qemu64") {
+		if strings.HasPrefix(cpu, "qemu64") && runtime.GOOS != "windows" {
 			// use q35 machine with vmware io port disabled.
 			args = appendArgsIfNoConflict(args, "-machine", "q35,vmport=off")
 			// use tcg accelerator with multi threading with 512MB translation block size
@@ -379,6 +379,9 @@ func Cmdline(cfg Config) (string, []string, error) {
 			args = appendArgsIfNoConflict(args, "-accel", "tcg,thread=multi,tb-size=512")
 			// This will disable CPU S3 state.
 			args = append(args, "-global", "ICH9-LPC.disable_s3=1")
+		} else if runtime.GOOS == "windows" && accel == "whpx" {
+			// whpx: injection failed, MSI (0, 0) delivery: 0, dest_mode: 0, trigger mode: 0, vector: 0
+			args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel+",kernel-irqchip=off")
 		} else {
 			args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel)
 		}
@@ -608,7 +611,7 @@ func getAccel(arch limayaml.Arch) string {
 		case "netbsd":
 			return "nvmm"
 		case "windows":
-			return "whpx" // untested
+			return "whpx"
 		}
 	}
 	return "tcg"


Test patch:
diff --git a/pkg/limayaml/defaults_test.go b/pkg/limayaml/defaults_test.go
index 5fedc5d2..f31eab03 100644
--- a/pkg/limayaml/defaults_test.go
+++ b/pkg/limayaml/defaults_test.go
@@ -86,7 +86,7 @@ func TestFillDefault(t *testing.T) {
 	if IsAccelOS() {
 		if HasHostCPU() {
 			builtin.CPUType[arch] = "host"
-		} else {
+		} else if HasMaxCPU() {
 			builtin.CPUType[arch] = "max"
 		}
 	}
Repository: attic-labs/noms
Pull request #3873 (2020-04-10 17:40:07)

fix mapeditor bug
Finishing #3872

arv: FYI @phritz @aboodman 

Patch:
diff --git a/go/types/map_editor.go b/go/types/map_editor.go
index f5571649..669154f6 100644
--- a/go/types/map_editor.go
+++ b/go/types/map_editor.go
@@ -150,10 +150,7 @@ func (me *MapEditor) Remove(k Value) *MapEditor {
 
 func (me *MapEditor) Get(k Value) Valuable {
 	if idx, found := me.findEdit(k); found {
-		v := me.edits[idx].value
-		if v != nil {
-			return v
-		}
+		return me.edits[idx].value
 	}
 
 	return me.m.Get(k)


Test patch:
diff --git a/go/types/map_test.go b/go/types/map_test.go
index 05f90d4d..d5274cc2 100644
--- a/go/types/map_test.go
+++ b/go/types/map_test.go
@@ -547,6 +547,30 @@ func TestMapHas(t *testing.T) {
 	doTest(getTestRefToValueOrderMap, 2)
 }
 
+func TestMapRemoveMasksUnderlyingMap(t *testing.T) {
+	assert := assert.New(t)
+	vrw := newTestValueStore()
+
+	k := String("foo")
+	me := NewMap(vrw, k, String("bar")).Edit()
+	me.Remove(k)
+	assert.False(me.Has(k))
+	assert.Nil(me.Get(k))
+
+	two := Number(2)
+	me.Set(two, two)
+	me.Remove(two)
+	assert.False(me.Has(two))
+	assert.Nil(me.Get(two))
+
+	me2 := NewMap(vrw).Edit()
+	three := Number(3)
+	me.Set(three, me2)
+	me.Remove(three)
+	assert.False(me.Has(three))
+	assert.Nil(me.Get(three))
+}
+
 func TestMapHasRemove(t *testing.T) {
 	assert := assert.New(t)
 	vrw := newTestValueStore()
Repository: lima-vm/lima
Pull request #2673 (2024-10-02 05:02:44)

Make lima user fallback regex and cidata user validation consistent
This is a rework of #2655 as per the suggestion to use osutil user validation in cidata, rather than the other way around.


Patch:
diff --git a/pkg/cidata/template.go b/pkg/cidata/template.go
index aedc5caa..2a18ba43 100644
--- a/pkg/cidata/template.go
+++ b/pkg/cidata/template.go
@@ -11,6 +11,7 @@ import (
 	"github.com/lima-vm/lima/pkg/iso9660util"
 
 	"github.com/containerd/containerd/identifiers"
+	"github.com/lima-vm/lima/pkg/osutil"
 	"github.com/lima-vm/lima/pkg/textutil"
 )
 
@@ -92,8 +93,8 @@ func ValidateTemplateArgs(args TemplateArgs) error {
 	if err := identifiers.Validate(args.Name); err != nil {
 		return err
 	}
-	if err := identifiers.Validate(args.User); err != nil {
-		return err
+	if !osutil.ValidateUsername(args.User) {
+		return errors.New("field User must be valid linux username")
 	}
 	if args.User == "root" {
 		return errors.New("field User must not be \"root\"")
diff --git a/pkg/osutil/user.go b/pkg/osutil/user.go
index 98a987b7..7896d5e4 100644
--- a/pkg/osutil/user.go
+++ b/pkg/osutil/user.go
@@ -40,6 +40,10 @@ var regexUsername = regexp.MustCompile("^[a-z_][a-z0-9_-]*$")
 // regexPath detects valid Linux path.
 var regexPath = regexp.MustCompile("^[/a-zA-Z0-9_-]+$")
 
+func ValidateUsername(name string) bool {
+	return regexUsername.MatchString(name)
+}
+
 func LookupUser(name string) (User, error) {
 	if users == nil {
 		users = make(map[string]User)
@@ -111,7 +115,7 @@ func LimaUser(warn bool) (*user.User, error) {
 	cache.Do(func() {
 		cache.u, cache.err = user.Current()
 		if cache.err == nil {
-			if !regexUsername.MatchString(cache.u.Username) {
+			if !ValidateUsername(cache.u.Username) {
 				warning := fmt.Sprintf("local user %q is not a valid Linux username (must match %q); using %q username instead",
 					cache.u.Username, regexUsername.String(), fallbackUser)
 				cache.warnings = append(cache.warnings, warning)


Test patch:
diff --git a/pkg/osutil/user_test.go b/pkg/osutil/user_test.go
index 860f0a71..e68375ac 100644
--- a/pkg/osutil/user_test.go
+++ b/pkg/osutil/user_test.go
@@ -13,15 +13,11 @@ func TestLimaUserWarn(t *testing.T) {
 	assert.NilError(t, err)
 }
 
-func validUsername(username string) bool {
-	return regexUsername.MatchString(username)
-}
-
 func TestLimaUsername(t *testing.T) {
 	user, err := LimaUser(false)
 	assert.NilError(t, err)
 	// check for reasonable unix user name
-	assert.Assert(t, validUsername(user.Username), user.Username)
+	assert.Assert(t, ValidateUsername(user.Username), user.Username)
 }
 
 func TestLimaUserUid(t *testing.T) {
Repository: lima-vm/lima
Pull request #3405 (2025-04-04 23:55:10)

Remove redundant major version number from instance name
almalinux and rocky use image names that include the major version number twice. This commit strips it:

```
almalinux-8-8.10 → almalinux-8.10
almalinux-9-9.5  → almalinux-9.5
rocky-8-8.10     → rocky-8.10
rocky-9-9.5      → rocky-9.5
```


Patch:
diff --git a/pkg/limatmpl/locator.go b/pkg/limatmpl/locator.go
index b863081f..6ddf16a3 100644
--- a/pkg/limatmpl/locator.go
+++ b/pkg/limatmpl/locator.go
@@ -199,24 +199,36 @@ images:
 func InstNameFromImageURL(locator, imageArch string) string {
 	// We intentionally call both path.Base and filepath.Base in case we are running on Windows.
 	name := strings.ToLower(filepath.Base(path.Base(locator)))
-	// Remove file format and compression file types
+	// Remove file format and compression file types.
 	name = imageURLRegex.ReplaceAllString(name, "")
-	// The Alpine "nocloud_" prefix does not fit the genericTags pattern
+	// The Alpine "nocloud_" prefix does not fit the genericTags pattern.
 	name = strings.TrimPrefix(name, "nocloud_")
 	for _, tag := range genericTags {
 		re := regexp.MustCompile(fmt.Sprintf(`[-_.]%s\b`, tag))
 		name = re.ReplaceAllString(name, "")
 	}
-	// Remove imageArch as well if it is the native arch
+	// Remove imageArch as well if it is the native arch.
 	if limayaml.IsNativeArch(imageArch) {
 		re := regexp.MustCompile(fmt.Sprintf(`[-_.]%s\b`, imageArch))
 		name = re.ReplaceAllString(name, "")
 	}
 	// Remove timestamps from name: 8 digit date, optionally followed by
-	// a delimiter and one or more digits before a word boundary
+	// a delimiter and one or more digits before a word boundary.
 	name = regexp.MustCompile(`[-_.]20\d{6}([-_.]\d+)?\b`).ReplaceAllString(name, "")
 	// Normalize archlinux name
 	name = regexp.MustCompile(`^arch\b`).ReplaceAllString(name, "archlinux")
+	// Remove redundant major version, e.g. "rocky-8-8.10" becomes "rocky-8.10".
+	// Unfortunately regexp doesn't support back references, so we have to
+	// check manually if both numbers are the same.
+	re := regexp.MustCompile(`-(\d+)-(\d+)\.`)
+	name = re.ReplaceAllStringFunc(name, func(match string) string {
+		submatch := re.FindStringSubmatch(match)
+		if submatch[1] == submatch[2] {
+			// Replace -X-X. with -X.
+			return "-" + submatch[1] + "."
+		}
+		return match
+	})
 	return name
 }
 


Test patch:
diff --git a/pkg/limatmpl/locator_test.go b/pkg/limatmpl/locator_test.go
index dcd23361..dcf510c2 100644
--- a/pkg/limatmpl/locator_test.go
+++ b/pkg/limatmpl/locator_test.go
@@ -52,4 +52,12 @@ func TestInstNameFromImageURL(t *testing.T) {
 		name := limatmpl.InstNameFromImageURL(image, arch)
 		assert.Equal(t, name, "linux")
 	})
+	t.Run("removes redundant major version", func(t *testing.T) {
+		name := limatmpl.InstNameFromImageURL("rocky-8-8.10.raw", "unknown")
+		assert.Equal(t, name, "rocky-8.10")
+	})
+	t.Run("don't remove non-redundant major version", func(t *testing.T) {
+		name := limatmpl.InstNameFromImageURL("rocky-8-9.10.raw", "unknown")
+		assert.Equal(t, name, "rocky-8-9.10")
+	})
 }
Repository: lima-vm/lima
Pull request #3485 (2025-05-01 17:02:56)

Add dirnames.TemplatesDir() function
All other special directories have a symbolic filename and dirname function.


Patch:
diff --git a/pkg/store/dirnames/dirnames.go b/pkg/store/dirnames/dirnames.go
index 89118ed0..3d03a318 100644
--- a/pkg/store/dirnames/dirnames.go
+++ b/pkg/store/dirnames/dirnames.go
@@ -65,3 +65,12 @@ func LimaDisksDir() (string, error) {
 	}
 	return filepath.Join(limaDir, filenames.DisksDir), nil
 }
+
+// LimaTemplatesDir returns the path of the templates directory, $LIMA_HOME/_templates.
+func LimaTemplatesDir() (string, error) {
+	limaDir, err := LimaDir()
+	if err != nil {
+		return "", err
+	}
+	return filepath.Join(limaDir, filenames.TemplatesDir), nil
+}
diff --git a/pkg/store/filenames/filenames.go b/pkg/store/filenames/filenames.go
index 09f6c93b..cfb825fc 100644
--- a/pkg/store/filenames/filenames.go
+++ b/pkg/store/filenames/filenames.go
@@ -10,10 +10,11 @@ package filenames
 // Instance names starting with an underscore are reserved for lima internal usage
 
 const (
-	ConfigDir   = "_config"
-	CacheDir    = "_cache"    // not yet implemented
-	NetworksDir = "_networks" // network log files are stored here
-	DisksDir    = "_disks"    // disks are stored here
+	CacheDir     = "_cache" // not yet implemented
+	ConfigDir    = "_config"
+	DisksDir     = "_disks"     // disks are stored here
+	NetworksDir  = "_networks"  // network log files are stored here
+	TemplatesDir = "_templates" // user templates are stored here
 )
 
 // Filenames used inside the ConfigDir


Test patch:
diff --git a/pkg/templatestore/templatestore.go b/pkg/templatestore/templatestore.go
index b914e1f6..4695aa97 100644
--- a/pkg/templatestore/templatestore.go
+++ b/pkg/templatestore/templatestore.go
@@ -24,11 +24,11 @@ type Template struct {
 	Location string `json:"location"`
 }
 
-func TemplatesPaths() ([]string, error) {
+func templatesPaths() ([]string, error) {
 	if tmplPath := os.Getenv("LIMA_TEMPLATES_PATH"); tmplPath != "" {
 		return strings.Split(tmplPath, string(filepath.ListSeparator)), nil
 	}
-	limaDir, err := dirnames.LimaDir()
+	limaTemplatesDir, err := dirnames.LimaTemplatesDir()
 	if err != nil {
 		return nil, err
 	}
@@ -37,13 +37,13 @@ func TemplatesPaths() ([]string, error) {
 		return nil, err
 	}
 	return []string{
-		filepath.Join(limaDir, "_templates"),
+		limaTemplatesDir,
 		filepath.Join(shareDir, "templates"),
 	}, nil
 }
 
 func Read(name string) ([]byte, error) {
-	paths, err := TemplatesPaths()
+	paths, err := templatesPaths()
 	if err != nil {
 		return nil, err
 	}
@@ -68,7 +68,7 @@ func Read(name string) ([]byte, error) {
 const Default = "default"
 
 func Templates() ([]Template, error) {
-	paths, err := TemplatesPaths()
+	paths, err := templatesPaths()
 	if err != nil {
 		return nil, err
 	}
Repository: lima-vm/lima
Pull request #3638 (2025-06-19 16:23:11)

fix: correct validation error message when invalid provision
This PR fixes the validation error message that appears when an invalid provision mode is specified in lima.yaml, e.g. `provision: [{mode: invalid}]`.

Before (duplicated `"ansible"`):

```
field `provision[0].mode` must one of \"system\", \"user\", \"boot\", \"dependency\", \"ansible\", or \"ansible\
```

After:

```
field `provision[0].mode` must one of \"system\", \"user\", \"boot\", \"data\", \"dependency\", or \"ansible\"
```


Patch:
diff --git a/pkg/limayaml/validate.go b/pkg/limayaml/validate.go
index 750383e2..8298882c 100644
--- a/pkg/limayaml/validate.go
+++ b/pkg/limayaml/validate.go
@@ -219,7 +219,7 @@ func Validate(y *LimaYAML, warn bool) error {
 		case ProvisionModeSystem, ProvisionModeUser, ProvisionModeBoot, ProvisionModeData, ProvisionModeDependency, ProvisionModeAnsible:
 		default:
 			return fmt.Errorf("field `provision[%d].mode` must one of %q, %q, %q, %q, %q, or %q",
-				i, ProvisionModeSystem, ProvisionModeUser, ProvisionModeBoot, ProvisionModeDependency, ProvisionModeAnsible, ProvisionModeAnsible)
+				i, ProvisionModeSystem, ProvisionModeUser, ProvisionModeBoot, ProvisionModeData, ProvisionModeDependency, ProvisionModeAnsible)
 		}
 		if p.Mode != ProvisionModeDependency && p.SkipDefaultDependencyResolution != nil {
 			return fmt.Errorf("field `provision[%d].mode` cannot set skipDefaultDependencyResolution, only valid on scripts of type %q",


Test patch:
diff --git a/pkg/limayaml/validate_test.go b/pkg/limayaml/validate_test.go
index ed223382..d23db802 100644
--- a/pkg/limayaml/validate_test.go
+++ b/pkg/limayaml/validate_test.go
@@ -40,6 +40,37 @@ func TestValidateProbes(t *testing.T) {
 	assert.Error(t, err, "field `probe[0].file.digest` support is not yet implemented")
 }
 
+func TestValidateProvisionMode(t *testing.T) {
+	images := `images: [{location: /}]`
+	provisionBoot := `provision: [{mode: boot, script: "touch /tmp/param-$PARAM_BOOT"}]`
+	y, err := Load([]byte(provisionBoot+"\n"+images), "lima.yaml")
+	assert.NilError(t, err)
+
+	err = Validate(y, false)
+	assert.NilError(t, err)
+
+	provisionUser := `provision: [{mode: user, script: "touch /tmp/param-$PARAM_USER"}]`
+	y, err = Load([]byte(provisionUser+"\n"+images), "lima.yaml")
+	assert.NilError(t, err)
+
+	err = Validate(y, false)
+	assert.NilError(t, err)
+
+	provisionDependency := `provision: [{mode: ansible, script: "touch /tmp/param-$PARAM_DEPENDENCY"}]`
+	y, err = Load([]byte(provisionDependency+"\n"+images), "lima.yaml")
+	assert.NilError(t, err)
+
+	err = Validate(y, false)
+	assert.NilError(t, err)
+
+	provisionInvalid := `provision: [{mode: invalid}]`
+	y, err = Load([]byte(provisionInvalid+"\n"+images), "lima.yaml")
+	assert.NilError(t, err)
+
+	err = Validate(y, false)
+	assert.Error(t, err, "field `provision[0].mode` must one of \"system\", \"user\", \"boot\", \"data\", \"dependency\", or \"ansible\"")
+}
+
 func TestValidateProvisionData(t *testing.T) {
 	images := `images: [{location: /}]`
 	validData := `provision: [{mode: data, path: /tmp, content: hello}]`