{"record":{"id":"863c84e43b506b78","repo":"lima-vm/lima","slug":"invalid-network-name-q-w","errorCode":null,"errorMessage":"invalid network name %#q: %w","messagePattern":"invalid network name %#q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/networks/validate.go","lineNumber":36,"sourceCode":")\n\nfunc (c *Config) Validate() error {\n\t// The group name and the per-network name/mode/interface are interpolated\n\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() {","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/networks/validate.go#L18-L54","documentation":"Each network name in networks.yaml becomes a key used to build file paths and sudoers directives, so it must pass identifiers.Validate. An invalid name aborts config validation with the offending name quoted.","triggerScenarios":"Defining a network entry in <LIMA_HOME>/_config/networks.yaml whose key (e.g. under `networks:`) contains whitespace, slashes, newlines, or other non-identifier characters, then running validation via networks.Validate().","commonSituations":"Hand-edited networks.yaml with a typo like 'lima user-v2' or a name with a trailing colon/space; programmatically generated configs injecting bad keys; YAML merging producing unexpected key names.","solutions":["Rename the network key in networks.yaml to a valid identifier (letters, digits, underscore, hyphen where allowed) and update all instance YAML `networks` references to the new name.","Re-run validation to confirm no other entries fail.","Check for invisible characters (tabs, non-breaking spaces) with cat -A networks.yaml.","Regenerate the config from the stock template if multiple entries are broken."],"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":"function validateNetworkName(name) {\n  if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(name)) {\n    return `invalid network name: ${JSON.stringify(name)}`;\n  }\n  return null;\n}\nObject.keys(config.networks).forEach(validateNetworkName);","typeGuard":"function isValidNetworkName(name) {\n  return typeof name === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(name);\n}","tryCatchPattern":null,"preventionTips":["Use kebab-case names without spaces for network entries.","Check for invisible characters with `cat -A networks.yaml`.","Keep network names in sync with `networks:` references in instance YAML.","Lint networks.yaml with yamllint."],"tags":["config","validation","networks-yaml","naming"],"backgroundTag":"invalid-identifier","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}