{"record":{"id":"2918d221e1896e9f","repo":"lima-vm/lima","slug":"invalid-mode-q-for-network-q-w","errorCode":null,"errorMessage":"invalid mode %#q for network %#q: %w","messagePattern":"invalid mode %#q for network %#q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/networks/validate.go","lineNumber":40,"sourceCode":"\t// verbatim into the sudoers file (sudoers.go) and into the socket_vmnet\n\t// command that reconcile.go runs via sudo after splitting it on spaces\n\t// (commands.go). A value with whitespace injects an extra argument, and a\n\t// newline in a network name adds an arbitrary directive to the generated\n\t// sudoers file, so require them to be valid identifiers. Interface is empty\n\t// for non-bridged networks, and group defaults to \"admin\" when unset, so\n\t// only validate those when a value is actually present.\n\tif c.Group != \"\" {\n\t\tif err := identifiers.Validate(c.Group); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid group %#q: %w\", c.Group, err)\n\t\t}\n\t}\n\tfor name, nw := range c.Networks {\n\t\tif err := identifiers.Validate(name); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid network name %#q: %w\", name, err)\n\t\t}\n\t\tif nw.Mode != \"\" {\n\t\t\tif err := identifiers.Validate(nw.Mode); err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid mode %#q for network %#q: %w\", nw.Mode, name, err)\n\t\t\t}\n\t\t}\n\t\tif nw.Interface != \"\" {\n\t\t\tif err := identifiers.Validate(nw.Interface); err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid interface %#q for network %#q: %w\", nw.Interface, name, err)\n\t\t\t}\n\t\t}\n\t}\n\n\t// validate all paths.* values\n\tpaths := reflect.ValueOf(&c.Paths).Elem()\n\tpathsMap := make(map[string]string, paths.NumField())\n\tvar socketVMNetNotFound bool\n\tfor i := range paths.NumField() {\n\t\t// extract YAML name from struct tag; strip options like \"omitempty\"\n\t\tname := paths.Type().Field(i).Tag.Get(\"yaml\")\n\t\tif i := strings.IndexRune(name, ','); i > -1 {\n\t\t\tname = name[:i]","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/networks/validate.go#L22-L58","documentation":"A network's `mode` (e.g. host, user-v2, bridged) is embedded in generated sudoers/daemon arguments, so it must be a valid identifier; otherwise validation fails quoting both the mode and network name.","triggerScenarios":"Setting `mode:` for a network in networks.yaml to a misspelled or malformed value (spaces, symbols, wrong case tricks) and calling networks.Validate().","commonSituations":"Typos like 'user v2' or 'host\\n'; adding a new experimental mode string with invalid characters; copy-paste from docs with trailing whitespace.","solutions":["Fix the `mode` value to one of the supported identifiers (host, shared, bridged, user-v2).","Check YAML indentation so the mode belongs to the intended network entry.","Re-run limactl start / networks.Validate() after the edit.","If you intended a bridged interface, configure it via `interface:` not `mode:`."],"exampleFix":"# before (networks.yaml)\nnetworks:\n  lima-user-v2:\n    mode: \"user v2\"\n# after\nnetworks:\n  lima-user-v2:\n    mode: user-v2","handlingStrategy":"validation","validationCode":"const validModes = ['host','shared','bridged','user-v2'];\nfunction validateMode(mode, name) {\n  if (!mode) return null;\n  if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(mode)) return `invalid mode '${mode}' for network ${name}`;\n  if (!validModes.includes(mode)) return `unknown mode '${mode}' (expected one of ${validModes.join(', ')})`;\n  return null;\n}","typeGuard":"function isValidMode(mode) {\n  return !mode || (typeof mode === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(mode));\n}","tryCatchPattern":null,"preventionTips":["Only use documented mode values: host, shared, bridged, user-v2.","Trim trailing whitespace from YAML values.","Don't put interface names in the mode field.","Validate networks.yaml after every manual edit."],"tags":["config","validation","networks-yaml","mode"],"backgroundTag":"invalid-identifier","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}