{"record":{"id":"966d49de8cbdccba","repo":"hashicorp/nomad","slug":"invalid-interface-name-q","errorCode":null,"errorMessage":"invalid interface name %q","messagePattern":"invalid interface name %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/config.go","lineNumber":2464,"sourceCode":"\t\t// unable to parse template \"{{printfl \\\"en50\\\"}}\": template: sockaddr.Parse:1: function \"printfl\" not defined\n\t\treturn \"\", err\n\t}\n\n\t// Remove any extra empty space around the rendered result and check if the\n\t// result is also not empty if the user provided a template.\n\tout = strings.TrimSpace(out)\n\tif tpl != \"\" && out == \"\" {\n\t\treturn \"\", fmt.Errorf(\"template %q evaluated to empty result\", tpl)\n\t}\n\n\t// `template.Parse` returns a space-separated list of results, but on\n\t// Windows network interfaces are allowed to have spaces, so there is no\n\t// guaranteed separators that we can use to test if the template returned\n\t// multiple interfaces.\n\t// The test below checks if the template results to a single valid interface.\n\t_, err = net.InterfaceByName(out)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid interface name %q\", out)\n\t}\n\n\treturn out, nil\n}\n\n// parseMultipleIPTemplate is used as a helper function to parse out a multiple IP\n// addresses from a config parameter.\nfunc parseMultipleIPTemplate(ipTmpl string) ([]string, error) {\n\tout, err := template.Parse(ipTmpl)\n\tif err != nil {\n\t\treturn []string{}, fmt.Errorf(\"Unable to parse address template %q: %v\", ipTmpl, err)\n\t}\n\n\tips := strings.Split(out, \" \")\n\tif len(ips) == 0 {\n\t\treturn []string{}, errors.New(\"No addresses found, please configure one.\")\n\t}\n","sourceCodeStart":2446,"sourceCodeEnd":2482,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/config.go#L2446-L2482","documentation":"After rendering the network_interface template, parseSingleInterfaceTemplate validates that the result is a real network interface using net.InterfaceByName. If the OS reports no interface with that name, the code returns 'invalid interface name %q' instead of continuing with a bogus interface.","triggerScenarios":"client.network_interface (after template evaluation) naming an interface that does not exist on the host, e.g. 'eth1' on a single-NIC machine, or a template filter returning a raw IP rather than an interface name expected by InterfaceByName.","commonSituations":"Hardcoded interface names that differ across environments (eth0 vs ens192 vs enp0s3); renamed NICs after re-provisioning; typos in static interface names in config.","solutions":["Run `ip link` (Linux) or `ifconfig` (macOS/BSD) and use an existing interface name","Prefer a template like {{ GetInterfaceIP \"eth0\" }} over hardcoding names","Update machine provisioning/terraform so interface names are consistent","Check the quoted name in the error against the host's actual interfaces"],"exampleFix":"// before\nclient { network_interface = \"eth1\" } # does not exist\n// after\nclient { network_interface = \"eth0\" }","handlingStrategy":"validation","validationCode":"name := strings.TrimSpace(rendered)\nif _, err := net.InterfaceByName(name); err != nil {\n\t// not a real interface: pick one from `ip link`\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enumerate interfaces with `ip link` before hardcoding names","Use {{ GetInterfaceIP }} templates rather than literal names","Standardize NIC naming across environments"],"tags":["config","network","interface"],"backgroundTag":"invalid-network-interface","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}