{"record":{"id":"65a974b36c46d715","repo":"hashicorp/nomad","slug":"client-service-name-must-be-set-when-auto-advertis","errorCode":null,"errorMessage":"client_service_name must be set when auto_advertise is enabled","messagePattern":"client_service_name must be set when auto_advertise is enabled","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/agent.go","lineNumber":1063,"sourceCode":"\t} else if agentConfig.Client.Reserved.Cores != \"\" {\n\t\tcores := idset.Parse[hw.CoreID](agentConfig.Client.Reserved.Cores)\n\t\tres.Cpu.ReservedCpuCores = helper.ConvertSlice(\n\t\t\tcores.Slice(),\n\t\t\tfunc(id hw.CoreID) uint16 { return uint16(id) },\n\t\t)\n\t}\n\n\tconf.Version = agentConfig.Version\n\n\t// Set the Consul configurations\n\tconf.ConsulConfigs = helper.SliceToMap[map[string]*config.ConsulConfig](\n\t\tagentConfig.Consuls,\n\t\tfunc(cfg *config.ConsulConfig) string { return cfg.Name },\n\t)\n\n\tconsul := conf.ConsulConfigs[structs.ConsulDefaultCluster]\n\tif *consul.AutoAdvertise && consul.ClientServiceName == \"\" {\n\t\treturn nil, fmt.Errorf(\"client_service_name must be set when auto_advertise is enabled\")\n\t}\n\n\t// Set the Vault configurations\n\tconf.VaultConfigs = helper.SliceToMap[map[string]*config.VaultConfig](\n\t\tagentConfig.Vaults,\n\t\tfunc(cfg *config.VaultConfig) string { return cfg.Name },\n\t)\n\n\t// Set up Telemetry configuration\n\tconf.StatsCollectionInterval = agentConfig.Telemetry.collectionInterval\n\tconf.PublishNodeMetrics = agentConfig.Telemetry.PublishNodeMetrics\n\tconf.PublishAllocationMetrics = agentConfig.Telemetry.PublishAllocationMetrics\n\tconf.IncludeAllocMetadataInMetrics = agentConfig.Telemetry.IncludeAllocMetadataInMetrics\n\tconf.AllowedMetadataKeysInMetrics = agentConfig.Telemetry.AllowedMetadataKeysInMetrics\n\tconf.DisableAllocationHookMetrics = *agentConfig.Telemetry.DisableAllocationHookMetrics\n\n\t// Set the TLS related configs\n\tconf.TLSConfig = agentConfig.TLSConfig","sourceCodeStart":1045,"sourceCodeEnd":1081,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/agent.go#L1045-L1081","documentation":"convertClientConfig builds Consul configs and checks the default cluster's ConsulConfig: if AutoAdvertise is true, the client must advertise its services under a Consul service name, so ClientServiceName must be non-empty. When auto_advertise is enabled and client_service_name is blank, configuration fails with this message.","triggerScenarios":"A consul { auto_advertise = true } block (default cluster) in the agent config without client_service_name set, evaluated during agent startup or config reload (handleReload).","commonSituations":"Enabling Consul auto-advertise but forgetting the required client_service_name; minimal config examples omitting it; migrating to multi-cluster consul config where the default cluster entry lost its service name field.","solutions":["Add client_service_name = \"nomad-client\" inside the consul block.","Or set auto_advertise = false if Consul advertisement is not wanted.","Verify the consul block being validated is the default cluster's config."],"exampleFix":"// before\nconsul {\n  auto_advertise = true\n}\n// after\nconsul {\n  auto_advertise = true\n  client_service_name = \"nomad-client\"\n}","handlingStrategy":"validation","validationCode":"if consulCfg.AutoAdvertise != nil && *consulCfg.AutoAdvertise && consulCfg.ClientServiceName == \"\" {\n  return errors.New(\"consul.client_service_name is required when auto_advertise = true\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pair every auto_advertise = true with client_service_name in the same consul block.","Keep a canonical consul config template including client_service_name = \"nomad-client\".","Validate agent configs in CI before deployment."],"tags":["config","nomad","consul"],"backgroundTag":"missing-required-config-field","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}