{"record":{"id":"d697b477bf004948","repo":"lima-vm/lima","slug":"the-yaml-is-invalid-saved-the-buffer-as-q-w-d697b4","errorCode":null,"errorMessage":"the YAML is invalid, saved the buffer as %#q: %w","messagePattern":"the YAML is invalid, saved the buffer as %#q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/instance/create.go","lineNumber":65,"sourceCode":"\t// limayaml.Load() needs to pass the store file path to limayaml.FillDefault() to calculate default MAC addresses\n\tfilePath := filepath.Join(instDir, filenames.LimaYAML)\n\tloadedInstConfig, err := limayaml.LoadWithWarnings(ctx, instConfig, filePath)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\t// If VMType is not specified, we go with the default platform driver.\n\tif err := driverutil.ResolveVMType(loadedInstConfig); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := limayaml.Validate(loadedInstConfig, false); err != nil {\n\t\tif !saveBrokenYAML {\n\t\t\treturn nil, err\n\t\t}\n\t\trejectedYAML := \"lima.REJECTED.yaml\"\n\t\tif writeErr := os.WriteFile(rejectedYAML, instConfig, 0o644); writeErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"the YAML is invalid, attempted to save the buffer as %#q but failed: %w: %w\", rejectedYAML, writeErr, err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"the YAML is invalid, saved the buffer as %#q: %w\", rejectedYAML, err)\n\t}\n\tif err := os.MkdirAll(instDir, 0o700); err != nil {\n\t\treturn nil, err\n\t}\n\tvar createSucceeded bool\n\tdefer func() {\n\t\tserver.Stop(instDir, true)\n\t\tif !createSucceeded {\n\t\t\t_ = os.RemoveAll(instDir)\n\t\t}\n\t}()\n\n\tif err := os.WriteFile(filePath, instConfig, 0o644); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := os.WriteFile(filepath.Join(instDir, filenames.LimaVersion), []byte(version.Version), 0o444); err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/instance/create.go#L47-L83","documentation":"limactl instance creation rejected the user's lima.yml because limayaml.Validate() failed during pkg/instance.Create. When the caller opts into saveBrokenYAML, Lima writes the raw input buffer to lima.REJECTED.yaml in the current directory so the user can inspect and fix it, then wraps the validation error with the file name. It is a config-validation guard, not a runtime failure.","triggerScenarios":"Calling instance.Create(ctx, instName, instConfig, true) where the YAML parses and loads (limayaml.LoadWithWarnings succeeds at create.go:49) but fails the first strict=false limayaml.Validate at create.go:57, AND os.WriteFile(\"lima.REJECTED.yaml\", ...) succeeds.","commonSituations":"Hand-written lima.yml with invalid field values (bad arch, unknown vmType, invalid port/forward rules, images without valid URL/arch), deprecated or conflicting fields, or a template filled in with wrong placeholder values.","solutions":["Open lima.REJECTED.yaml in the current working directory; the wrapped %w error names each offending field.","Fix the listed fields in your lima.yml (run `limactl validate <file>` if available, or compare against templates/ examples).","If the value depends on host capability, check `limactl info` output for supported arch/vmType.","Pass saveBrokenYAML=false if you want the bare validation error without the saved file."],"exampleFix":"// before\ncpus: \"not-a-number\"\n// after\ncpus: 4","handlingStrategy":"validation","validationCode":"if err := limayaml.Validate(cfg, false); err != nil {\n    return fmt.Errorf(\"invalid lima.yml: %w\", err)\n}\n// or CLI: limactl validate my.yaml before create","typeGuard":null,"tryCatchPattern":"if _, err := instance.Create(ctx, name, buf, true); err != nil {\n    if strings.Contains(err.Error(), \"lima.REJECTED.yaml\") {\n        // inspect the saved file for the offending config\n    }\n    return err\n}","preventionTips":["Start from an up-to-date template in templates/ rather than hand-writing YAML","Run `limactl validate <file>` before every create","Validate YAML after template substitution, not before"],"tags":["yaml","config-validation","limactl"],"backgroundTag":"schema-validation-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}