{"record":{"id":"818ad24f1d692614","repo":"hashicorp/nomad","slug":"task-for-consul-connect-native-service-s-s-is-a","errorCode":null,"errorMessage":"task for Consul Connect Native service %s->%s is ambiguous and must be set","messagePattern":"task for Consul Connect Native service (.+?)->(.+?) is ambiguous and must be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/job_endpoint_hook_connect.go","lineNumber":228,"sourceCode":"}\n\nfunc isTerminatingGatewayForService(t *structs.Task, svc string) bool {\n\treturn t.Kind == structs.NewTaskKind(structs.ConnectTerminatingPrefix, svc)\n}\n\nfunc isMeshGatewayForService(t *structs.Task, svc string) bool {\n\treturn t.Kind == structs.NewTaskKind(structs.ConnectMeshPrefix, svc)\n}\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","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/job_endpoint_hook_connect.go#L210-L246","documentation":"Fires in getNamedTaskForNativeService when a Connect-native service names no task and the group contains more than one task: Nomad cannot infer which task exposes the service, so the task name must be set explicitly.","triggerScenarios":"Thrown at nomad/job_endpoint_hook_connect.go:228 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the task field on the group's connect-native service block","Or reduce the group to a single task so the name can be inferred"],"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"}