{"record":{"id":"6608cfb8b26a9306","repo":"hashicorp/nomad","slug":"invalid-port-q-port-label-not-found","errorCode":null,"errorMessage":"invalid port %q: port label not found","messagePattern":"invalid port %q: port label not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/serviceregistration/address.go","lineNumber":85,"sourceCode":"\t\t}\n\n\t\t// Default path: use host ip:port\n\t\t// Try finding port in the AllocatedPorts struct first\n\t\t// Check in Networks struct for backwards compatibility if not found\n\t\tmapping, ok := ports.Get(portLabel)\n\t\tif !ok {\n\t\t\tmapping = networks.Port(portLabel)\n\t\t\tif mapping.Value > 0 {\n\t\t\t\treturn mapping.HostIP, mapping.Value, nil\n\t\t\t}\n\n\t\t\t// If port isn't a label, try to parse it as a literal port number\n\t\t\tport, err := strconv.Atoi(portLabel)\n\t\t\tif err != nil {\n\t\t\t\t// Don't include Atoi error message as user likely\n\t\t\t\t// never intended it to be a numeric and it creates a\n\t\t\t\t// confusing error message\n\t\t\t\treturn \"\", 0, fmt.Errorf(\"invalid port %q: port label not found\", portLabel)\n\t\t\t}\n\t\t\tif port <= 0 {\n\t\t\t\treturn \"\", 0, fmt.Errorf(\"invalid port: %q: port must be >0\", portLabel)\n\t\t\t}\n\n\t\t\t// A number was given which will use the Consul agent's address and the given port\n\t\t\t// Returning a blank string as an address will use the Consul agent's address\n\t\t\treturn \"\", port, nil\n\t\t}\n\t\treturn mapping.HostIP, mapping.Value, nil\n\n\tcase structs.AddressModeDriver:\n\t\t// Cannot use address mode driver with custom advertise address.\n\t\tif address != \"\" {\n\t\t\treturn \"\", 0, fmt.Errorf(\"cannot use custom advertise address with %q address mode\", structs.AddressModeDriver)\n\t\t}\n\n\t\t// Require a driver network if driver address mode is used","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/serviceregistration/address.go#L67-L103","documentation":"In GetAddress's default (host) path, the port label is not found in AllocatedPorts or Networks and is not numeric, so the service registration cannot resolve a host port. Typically a missing port label in the network block or a misnamed dynamic port.","triggerScenarios":"Thrown at client/serviceregistration/address.go:85 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the port label to the task/group network resources","Reference an existing label from the port map","Use a numeric port if static"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}