{"record":{"id":"39f1b2d69098483a","repo":"hashicorp/nomad","slug":"service-s-is-connect-native-and-requires-setting","errorCode":null,"errorMessage":"Service %s is Connect Native and requires setting the task","messagePattern":"Service (.+?) is Connect Native and requires setting the task","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":895,"sourceCode":"\tcase api.ServiceKindTypical,\n\t\tapi.ServiceKindAPIGateway,\n\t\tapi.ServiceKindIngressGateway,\n\t\tapi.ServiceKindMeshGateway,\n\t\tapi.ServiceKindTerminatingGateway:\n\tdefault:\n\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Service %s kind must be one of consul service kind or empty\", s.Name))\n\t}\n\n\t// check connect\n\tif s.Connect != nil {\n\t\tif err := s.Connect.Validate(); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t}\n\n\t\t// if service is connect native, service task must be set (which may\n\t\t// happen implicitly in a job mutation if there is only one task)\n\t\tif s.Connect.IsNative() && len(s.TaskName) == 0 {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Service %s is Connect Native and requires setting the task\", s.Name))\n\t\t}\n\n\t\t// if service is connect native a port must be set on the service or consul will reject it\n\t\tif s.Connect.IsNative() && s.PortLabel == \"\" {\n\t\t\tmErr.Errors = append(mErr.Errors, fmt.Errorf(\"Service %s is Connect Native and requires setting the port\", s.Name))\n\t\t}\n\t}\n}\n\n// validateNomadService performs validation on a service which is using the\n// nomad provider.\nfunc (s *Service) validateNomadService(mErr *multierror.Error) {\n\t// check checks\n\tfor _, c := range s.Checks {\n\t\t// validate the check port\n\t\tif err := s.validateCheckPort(c); err != nil {\n\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\tcontinue","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L877-L913","documentation":"When a service is Connect Native (connect { sidecar_service {} } with native via service registration flags — Connect.IsNative()), Nomad requires the `task` field on the service so the service can be attributed to and run within a specific task's namespace. If the task name is empty, validation fails. Normally job mutation fills this implicitly when there is only one task, so this error mostly appears in multi-task groups.","triggerScenarios":"A Connect Native service (Connect.IsNative() true) in a task group with multiple tasks where `task` is not set on the service stanza.","commonSituations":"Multi-task allocations with a Connect Native service; manually written jobs omitting the task field; jobs copied from single-task examples into multi-task groups.","solutions":["Add `task = \"<task-name>\"` to the service stanza naming the task that is Connect Native.","Ensure the connect stanza is marked native (and the task binary actually supports Connect Native).","If the service is not meant to be native, remove the native configuration so the sidecar path is used."],"exampleFix":"// before\nservice {\n  name = \"native-svc\"\n  connect { sidecar_service {} }\n}\n// after\nservice {\n  name = \"native-svc\"\n  task = \"app\"\n  connect { sidecar_service {} }\n}","handlingStrategy":"validation","validationCode":"if svc.Connect != nil && svc.Connect.IsNative() && svc.TaskName == \"\" {\n  return fmt.Errorf(\"connect-native service %q must set task\", svc.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set `task` on service stanzas in multi-task groups","Only mark services native when the app binary supports Connect Native","Review group stanzas whenever the task count changes"],"tags":["nomad","consul-connect","connect-native","validation"],"backgroundTag":"connect-native-missing-task","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"}