{"record":{"id":"1d842ad66d701187","repo":"hashicorp/nomad","slug":"task-s-named-by-consul-connect-native-service-s","errorCode":null,"errorMessage":"task %s named by Consul Connect Native service %s->%s does not exist","messagePattern":"task (.+?) named by Consul Connect Native service (.+?)->(.+?) does not exist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint_hook_connect.go","lineNumber":236,"sourceCode":"}\n\n// getNamedTaskForNativeService retrieves the Task with the name specified in the\n// group service definition. If the task name is empty and there is only one task\n// in the group, infer the name from the only option.\nfunc getNamedTaskForNativeService(tg *structs.TaskGroup, serviceName, taskName string) (*structs.Task, error) {\n\tif taskName == \"\" {\n\t\tif len(tg.Tasks) == 1 {\n\t\t\treturn tg.Tasks[0], nil\n\t\t}\n\t\treturn nil, fmt.Errorf(\"task for Consul Connect Native service %s->%s is ambiguous and must be set\", tg.Name, serviceName)\n\t}\n\n\tfor _, t := range tg.Tasks {\n\t\tif t.Name == taskName {\n\t\t\treturn t, nil\n\t\t}\n\t}\n\treturn nil, fmt.Errorf(\"task %s named by Consul Connect Native service %s->%s does not exist\", taskName, tg.Name, serviceName)\n}\n\nfunc injectPort(group *structs.TaskGroup, label string) {\n\t// check that port hasn't already been defined before adding it to tg\n\tfor _, p := range group.Networks[0].DynamicPorts {\n\t\tif p.Label == label {\n\t\t\treturn\n\t\t}\n\t}\n\n\t// inject a port of label that maps inside the bridge namespace\n\tgroup.Networks[0].DynamicPorts = append(group.Networks[0].DynamicPorts, structs.Port{\n\t\tLabel: label,\n\t\t// -1 is a sentinel value to instruct the\n\t\t// scheduler to map the host's dynamic port to\n\t\t// the same port in the netns.\n\t\tTo: -1,\n\t})","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint_hook_connect.go#L218-L254","documentation":"Fires in getNamedTaskForNativeService when the service's task name does not match any task in the task group — the Connect-native service points at a task that does not exist.","triggerScenarios":"Thrown at nomad/job_endpoint_hook_connect.go:236 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Correct the task name in the connect-native service to match an existing task in the group"],"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"}