{"record":{"id":"de7ab23876bca66b","repo":"hashicorp/nomad","slug":"invalid-address-mode-q-de7ab2","errorCode":null,"errorMessage":"invalid address_mode %q","messagePattern":"invalid address_mode %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/services.go","lineNumber":315,"sourceCode":"\n\t// validate the initial status\n\tswitch sc.InitialStatus {\n\tcase \"\":\n\tcase api.HealthPassing:\n\tcase api.HealthWarning:\n\tcase api.HealthCritical:\n\tdefault:\n\t\treturn fmt.Errorf(`invalid initial check state (%s), must be one of %q, %q, %q or empty`, sc.InitialStatus, api.HealthPassing, api.HealthWarning, api.HealthCritical)\n\t}\n\n\t// validate address_mode\n\tswitch sc.AddressMode {\n\tcase \"\", AddressModeHost, AddressModeDriver, AddressModeAlloc, AddressModeAllocIPv6:\n\t\t// Ok\n\tcase AddressModeAuto:\n\t\treturn fmt.Errorf(\"invalid address_mode %q - %s only valid for services\", sc.AddressMode, AddressModeAuto)\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid address_mode %q\", sc.AddressMode)\n\t}\n\n\t// validate on_update\n\tswitch sc.OnUpdate {\n\tcase \"\", OnUpdateIgnore, OnUpdateRequireHealthy, OnUpdateIgnoreWarn:\n\t\t// OK\n\tdefault:\n\t\treturn fmt.Errorf(\"on_update must be %q, %q, or %q; got %q\", OnUpdateRequireHealthy, OnUpdateIgnoreWarn, OnUpdateIgnore, sc.OnUpdate)\n\t}\n\n\t// validate check_restart and on_update do not conflict\n\tif sc.CheckRestart != nil {\n\t\t// CheckRestart and OnUpdate Ignore are incompatible If OnUpdate treats\n\t\t// an error has healthy, and the deployment succeeds followed by check\n\t\t// restart restarting failing checks, the deployment is left in an odd\n\t\t// state\n\t\tif sc.OnUpdate == OnUpdateIgnore {\n\t\t\treturn fmt.Errorf(\"on_update value %q is not compatible with check_restart\", sc.OnUpdate)","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/services.go#L297-L333","documentation":"Raised by ServiceCheck.validateCommon when a check's address_mode is a string that is not one of the recognized modes: \"\" (unset), host, driver, alloc, or alloc_ipv6. Unlike the \"auto\" case, this means the value did not match any known address mode at all, typically a typo or a mode from a different/newer Nomad version.","triggerScenarios":"Submitting a job with check { address_mode = \"container\" } or any unrecognized string, via nomad job run or the jobs API.","commonSituations":"Typos like \"hosts\" or \"drier\"; using address modes from other platforms (e.g. \"container\" from Docker wording); running a job spec written for a newer Nomad that supports a mode this binary does not know.","solutions":["Correct the address_mode value to one of: host, driver, alloc, alloc_ipv6, or remove it to use the default","Check the Nomad version's supported address modes against the job spec","Check for typos in the value","Run nomad job validate to confirm"],"exampleFix":"// before\ncheck {\n  address_mode = \"container\"\n  type         = \"http\"\n  path         = \"/health\"\n}\n// after\ncheck {\n  address_mode = \"driver\"\n  type         = \"http\"\n  path         = \"/health\"\n}","handlingStrategy":"validation","validationCode":"// Go: check address_mode against the known set\nvar validAddrModes = map[string]bool{\n\t\"\": true, \"host\": true, \"driver\": true, \"alloc\": true, \"alloc_ipv6\": true,\n}\nif !validAddrModes[check.AddressMode] {\n\treturn fmt.Errorf(\"address_mode %q not recognized\", check.AddressMode)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only documented values: host, driver, alloc, alloc_ipv6","Confirm the target Nomad version supports the address mode used","Enable editor schema validation/HCL linting for job files","Run `nomad job validate` in CI"],"tags":["nomad","service-check","address-mode","config-validation"],"backgroundTag":"invalid-enum-value","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"}