{"record":{"id":"06b1a90857c7752a","repo":"hashicorp/nomad","slug":"connect-configuration-empty-for-service-s","errorCode":null,"errorMessage":"Connect configuration empty for service %s","messagePattern":"Connect configuration empty for service (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/consul/connect.go","lineNumber":49,"sourceCode":"\n\tcase nc.IsNative():\n\t\t// the service is connect native\n\t\treturn &api.AgentServiceConnect{Native: true}, nil\n\n\tcase nc.HasSidecar():\n\t\t// must register the sidecar for this service\n\t\tif nc.SidecarService.Port == \"\" {\n\t\t\tnc.SidecarService.Port = fmt.Sprintf(\"%s-%s\", structs.ConnectProxyPrefix, serviceName)\n\t\t}\n\t\tsidecarReg, err := connectSidecarRegistration(serviceID, info, nc.SidecarService, networks, ports)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &api.AgentServiceConnect{SidecarService: sidecarReg}, nil\n\n\tdefault:\n\t\t// a non-nil but empty connect block makes no sense\n\t\treturn nil, fmt.Errorf(\"Connect configuration empty for service %s\", serviceName)\n\t}\n}\n\n// newConnectGateway creates a new Consul AgentServiceConnectProxyConfig struct based on\n// a Nomad Connect struct. If the Nomad Connect struct does not contain a gateway, nil\n// will be returned as this service is not a gateway.\nfunc newConnectGateway(connect *structs.ConsulConnect) *api.AgentServiceConnectProxyConfig {\n\tif !connect.IsGateway() {\n\t\treturn nil\n\t}\n\n\tvar envoyConfig map[string]any\n\n\t// Populate the envoy configuration from the gateway.proxy block, if\n\t// such configuration is provided.\n\tif proxy := connect.Gateway.Proxy; proxy != nil {\n\t\tenvoyConfig = make(map[string]any)\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/consul/connect.go#L31-L67","documentation":"newConnect builds a Consul AgentServiceConnect from a task's service definition. The 'default' branch of the switch is reached when the service has a non-nil but completely empty (zero-valued) connect block — no sidecar, no gateway, no native config — which is semantically meaningless, so Nomad rejects it.","triggerScenarios":"Declaring a connect stanza in a Nomad service that sets nothing (e.g. connect {} with no sidecar_service, gateway, or native), causing newConnect to fall through to the default case.","commonSituations":"Job authors write an empty connect block intending to enable sidecars but forget to configure the sidecar_service or gateway; jobs copied from examples where the meaningful fields were stripped.","solutions":["Populate the connect block: add a sidecar_service block, a gateway (ingress/terminating/mesh), or set native = true.","Remove the connect block entirely if Connect is not intended for this service.","Validate the job with nomad job validate before submission to catch the empty block."],"exampleFix":"// before\nservice {\n  name = \"web\"\n  connect {}\n}\n// after\nservice {\n  name = \"web\"\n  connect {\n    sidecar_service {}\n  }\n}","handlingStrategy":"validation","validationCode":"func connectBlockEmpty(c *structs.ConsulConnect) bool {\n  return c != nil && c.SidecarService == nil && c.Gateway == nil && !c.Native\n}\nif connectBlockEmpty(svc.Connect) {\n  return fmt.Errorf(\"service %s: connect block is empty\", svc.Name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never emit an empty connect stanza in HCL/JSON jobs.","Always pair connect with sidecar_service, gateway, or native = true.","Run nomad job validate before submitting jobs."],"tags":["consul","connect","configuration","nomad"],"backgroundTag":"empty-connect-config","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"}