{"record":{"id":"2c4a4fff53cb2a3a","repo":"hashicorp/nomad","slug":"unable-to-parse-address-template-q-v-2c4a4f","errorCode":null,"errorMessage":"Unable to parse address template %q: %v","messagePattern":"Unable to parse address template %q: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/config.go","lineNumber":2475,"sourceCode":"\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\n\treturn deduplicateAddrs(ips), nil\n}\n\n// normalizeAddrWithPort assumes that addr does not contain a port,\n// noramlizes it per ipv6 RFC-5942 §4, and appends \":{port}\".\nfunc normalizeAddrWithPort(addr string, port int) string {\n\treturn ipaddr.NormalizeAddr(net.JoinHostPort(addr, strconv.Itoa(port)))\n}\n\n// normalizeBind returns a normalized bind address.\n//","sourceCodeStart":2457,"sourceCodeEnd":2493,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/config.go#L2457-L2493","documentation":"parseMultipleIPTemplate renders a config value as a consul-template/go-sockaddr template expected to yield one or more space-separated IPs. If template.Parse fails (syntax error or evaluation failure), the error is wrapped as 'Unable to parse address template %q: %v'. It is used for multi-address fields such as addresses.http.","triggerScenarios":"Supplying a template string (e.g. in addresses.http) whose go-sockaddr/consul-template syntax is invalid: unclosed {{ }}, unknown function, or an expression that errors during evaluation.","commonSituations":"Copy-pasted templates with smart quotes or missing closing braces; unsupported go-sockaddr filter names; HCL escaping swallowing the braces; older agent versions lacking a newer template function.","solutions":["Fix the template syntax; ensure every {{ has a matching }}","Validate the expression with a go-sockaddr evaluation (e.g. `consul anchor` style or unit test the filter)","Check the wrapped %v message for the exact template failure","Use a plain IP list instead of a template if dynamic discovery is not required"],"exampleFix":"// before\naddresses { http = \"{{ GetInterfaceIPs \\\"eth0\\\"\" } # unclosed braces\n// after\naddresses { http = \"{{ GetInterfaceIPs \\\"eth0\\\" }}\" }","handlingStrategy":"validation","validationCode":"func validMultiIPTemplate(tmpl string) error {\n\tif !strings.HasPrefix(tmpl, \"{{\") { return nil }\n\tif !strings.HasSuffix(tmpl, \"}}\") { return errors.New(\"unbalanced braces\") }\n\tout, err := renderTemplate(tmpl)\n\tif err != nil { return err }\n\tfor _, ip := range strings.Fields(out) {\n\t\tif net.ParseIP(ip) == nil { return fmt.Errorf(\"bad IP %q\", ip) }\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Balance every {{ }} pair","Test templates with go-sockaddr before config rollout","Fall back to explicit space-separated IP lists where possible"],"tags":["config","template","network"],"backgroundTag":"address-template-parse-failed","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"}