{"record":{"id":"2a07a875ba451328","repo":"hashicorp/nomad","slug":"network-address-family-must-be-one-of-q-q","errorCode":null,"errorMessage":"network address family must be one of: \"\", %q, %q","messagePattern":"network address family must be one of: \"\", %q, %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":2740,"sourceCode":"\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\ntype NodeNetworkAF string\n\nconst (\n\tNodeNetworkAF_IPv4 NodeNetworkAF = \"ipv4\"\n\tNodeNetworkAF_IPv6 NodeNetworkAF = \"ipv6\"\n)\n\n// Validate validates that NodeNetworkAF has a legal value.\nfunc (n NodeNetworkAF) Validate() error {\n\tif n == \"\" || n == NodeNetworkAF_IPv4 || n == NodeNetworkAF_IPv6 {\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(`network address family must be one of: \"\", %q, %q`, NodeNetworkAF_IPv4, NodeNetworkAF_IPv6)\n}\n\ntype NodeNetworkAddress struct {\n\tFamily        NodeNetworkAF\n\tAlias         string\n\tAddress       string\n\tReservedPorts string\n\tGateway       string // default route for this address\n}\n\ntype AllocatedPortMapping struct {\n\t// msgpack omit empty fields during serialization\n\t_struct bool `codec:\",omitempty\"` // nolint: structcheck\n\n\tLabel           string\n\tValue           int\n\tTo              int\n\tHostIP          string","sourceCodeStart":2722,"sourceCodeEnd":2758,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L2722-L2758","documentation":"NodeNetworkAF.Validate() checks that a node's advertised network address family is one of the three legal values: empty string (unset), NodeNetworkAF_IPv4, or NodeNetworkAF_IPv6. Any other string in the NodeNetworkAF field of node network resources fails validation.","triggerScenarios":"Client configuration or a plugin setting NodeNetworkAF to an arbitrary string like \"ipv4\" (wrong case) or \"dual-stack\" instead of the exact enum constants; fingerprint code producing unexpected family values.","commonSituations":"Custom node fingerprint plugins emitting non-constant family strings; hand-crafted node registration payloads in tests or via the API; case sensitivity mistakes (IPv4 vs ipv4).","solutions":["Set the family to exactly NodeNetworkAF_IPv4 (\"ipv4\") or NodeNetworkAF_IPv6 (\"ipv6\") as defined by the constants","Leave the field as the empty string if the family is unknown/unset","Fix the fingerprint/plugin or payload generator to emit the canonical constant"],"exampleFix":"// before\nn.Family = \"IPV4\"\n// after\nn.Family = structs.NodeNetworkAF_IPv4 // \"ipv4\"","handlingStrategy":"type-guard","validationCode":"switch fam {\ncase \"\", structs.NodeNetworkAF_IPv4, structs.NodeNetworkAF_IPv6:\n    // ok\ndefault:\n    return fmt.Errorf(\"invalid network address family: %q\", fam)\n}","typeGuard":"func validNodeNetworkAF(n structs.NodeNetworkAF) bool {\n    return n == \"\" || n == structs.NodeNetworkAF_IPv4 || n == structs.NodeNetworkAF_IPv6\n}","tryCatchPattern":null,"preventionTips":["Only use the exported NodeNetworkAF_* constants, never raw strings","Watch case sensitivity: the constants are lowercase","Add unit tests for fingerprint plugins asserting valid family values"],"tags":["nomad","node","network","validation","enum"],"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"}