{"record":{"id":"040880fa56ea1523","repo":"lima-vm/lima","slug":"invalid-group-q-w","errorCode":null,"errorMessage":"invalid group %#q: %w","messagePattern":"invalid group %#q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/networks/validate.go","lineNumber":31,"sourceCode":"\t\"runtime\"\n\t\"strings\"\n\n\t\"github.com/lima-vm/lima/v2/pkg/identifiers\"\n\t\"github.com/lima-vm/lima/v2/pkg/osutil\"\n)\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","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/networks/validate.go#L13-L49","documentation":"pkg/networks validates each networks.yaml entry; since the group name is written into a generated sudoers file, it must be a valid identifier. identifiers.Validate(c.Group) failure is wrapped with the offending group name.","triggerScenarios":"Setting `group` for a network in <LIMA_HOME>/_config/networks.yaml to a value containing characters outside valid identifier syntax (spaces, newlines, slashes, quotes, etc.) and then loading/validating the config via networks.Validate().","commonSituations":"Copy-pasting a group name with a trailing space or shell metacharacters; editing networks.yaml by hand and accidentally introducing a newline; using a group name like 'wheel/admin'.","solutions":["Open networks.yaml and correct the `group` value to a plain identifier ([A-Za-z0-9_], no spaces/newlines).","Verify with `limactl` startup or the validation call again after editing.","If the group is intentionally special, create a plain-named OS group and add the needed users to it instead.","Quote-check YAML: ensure the value wasn't split across lines in the YAML file."],"exampleFix":"# before (networks.yaml)\nnetworks:\n  lima-user-v2:\n    group: \"adm in\"\n# after\nnetworks:\n  lima-user-v2:\n    group: admin","handlingStrategy":"validation","validationCode":"function validateGroupName(group) {\n  if (!group) return null; // empty defaults to admin\n  if (!/^[A-Za-z0-9_][A-Za-z0-9._-]*$/.test(group)) {\n    return `invalid group: ${group} (must be a plain identifier, no spaces/newlines)`;\n  }\n  return null;\n}\nvalidateGroupName(config.networks['lima-user-v2'].group);","typeGuard":"function isValidIdentifier(s) {\n  return typeof s === 'string' && /^[A-Za-z0-9_-]+$/.test(s);\n}","tryCatchPattern":null,"preventionTips":["Keep group names to letters/digits/underscore.","Avoid editing networks.yaml with editors that auto-wrap lines.","Trim whitespace from YAML values.","Validate the config with limactl before distributing it."],"tags":["config","validation","networks-yaml","sudoers"],"backgroundTag":"invalid-identifier","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}