{"record":{"id":"ea9c43a15c9b0792","repo":"lima-vm/lima","slug":"can-t-determine-instance-name-from-template-locato","errorCode":null,"errorMessage":"can't determine instance name from template locator %#q","messagePattern":"can't determine instance name from template locator %#q","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/limactl/template.go","lineNumber":257,"sourceCode":"\tfill, err := cmd.Flags().GetBool(\"fill\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tlimaDir, err := dirnames.LimaDir()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, arg := range args {\n\t\ttmpl, err := limatmpl.Read(ctx, \"\", arg)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif len(tmpl.Bytes) == 0 {\n\t\t\treturn fmt.Errorf(\"don't know how to interpret %#q as a template locator\", arg)\n\t\t}\n\t\tif tmpl.Name == \"\" {\n\t\t\treturn fmt.Errorf(\"can't determine instance name from template locator %#q\", arg)\n\t\t}\n\t\t// Embed default base.yaml only when fill is true.\n\t\tif err := tmpl.Embed(cmd.Context(), true, fill); err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// Load() will merge the template with override.yaml and default.yaml via FillDefaults().\n\t\t// FillDefaults() needs the potential instance directory to validate host templates using {{.Dir}}.\n\t\tfilePath := filepath.Join(limaDir, tmpl.Name+\".yaml\")\n\t\ty, err := limayaml.Load(ctx, tmpl.Bytes, filePath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t// If VMType is not specified, we go with the default platform driver.\n\t\tif err := driverutil.ResolveVMType(y); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif err := limayaml.Validate(y, false); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to validate YAML file %#q: %w\", arg, err)","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/cmd/limactl/template.go#L239-L275","documentation":"After successfully reading template bytes, `limactl template validate` requires an instance name to be derivable from the locator. `limatmpl.Read` only sets tmpl.Name when given an explicit name, a template URL, an http/file URL, or a YAML file path; when it cannot (e.g. reading from stdin `-` with no name), the name stays empty and validation aborts because later steps key off the instance name.","triggerScenarios":"Running `limactl template validate -` (reading YAML from stdin) where the YAML does not yield a name, or otherwise supplying a locator for which `InstNameFromYAMLPath`/`InstNameFromURL` cannot derive a name.","commonSituations":"Piping a config into validate: `cat my.yaml | limactl template validate -`; scripting validate with generated temp input; expecting validate to work like `create --name`.","solutions":["Validate from a named file instead of stdin: `limactl template validate ./my.yaml`","If using stdin is required, add an explicit name via the broader workflow (e.g. `limactl create --name=myinst -`) rather than `template validate -`","Ensure the file path ends in .yaml/.yml so the name can be derived from the basename","Check that the YAML has the fields expected to derive a name if relying on URL-based locators"],"exampleFix":"// before\ncat my.yaml | limactl template validate -\n// after\nlimactl template validate ./my.yaml","handlingStrategy":"validation","validationCode":"if arg == \"-\" {\n\treturn errors.New(\"template validate cannot derive an instance name from stdin; use a named .yaml file\")\n}\nif !strings.HasSuffix(arg, \".yaml\") && !strings.HasSuffix(arg, \".yml\") {\n\treturn fmt.Errorf(\"cannot derive instance name from %q\", arg)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer validating real files over stdin for `template validate`","Name template files after the intended instance (basename becomes the name)","Use `limactl create --name` when stdin input is required"],"tags":["cli","template","instance-name"],"backgroundTag":"missing-instance-name","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}