{"record":{"id":"3b0794d4da9cec90","repo":"hashicorp/nomad","slug":"duplicate-cni-arg-q","errorCode":null,"errorMessage":"duplicate CNI arg %q","messagePattern":"duplicate CNI arg %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/structs/structs.go","lineNumber":7384,"sourceCode":"\t\t\tif port.To < -1 {\n\t\t\t\terr := fmt.Errorf(\"Port %q cannot be mapped to negative value %d\", port.Label, port.To)\n\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t} else if port.To > math.MaxUint16 {\n\t\t\t\terr := fmt.Errorf(\"Port %q cannot be mapped to a port (%d) greater than %d\", port.Label, port.To, math.MaxUint16)\n\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t}\n\n\t\t\tif port.IgnoreCollision && !(net.Mode == \"\" || net.Mode == \"host\") {\n\t\t\t\terr := fmt.Errorf(\"Port %q collision may not be ignored on non-host network mode %q\", port.Label, net.Mode)\n\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t}\n\t\t}\n\t\t// Validate the cniArgs in each network resource. Make sure there are no duplicate Args in\n\t\t// different network resources or invalid characters (;) in key or value ;)\n\t\tif net.CNI != nil {\n\t\t\tfor k, v := range net.CNI.Args {\n\t\t\t\tif cniArgKeys.Contains(k) {\n\t\t\t\t\terr := fmt.Errorf(\"duplicate CNI arg %q\", k)\n\t\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t\t} else {\n\t\t\t\t\tcniArgKeys.Insert(k)\n\t\t\t\t}\n\t\t\t\t// CNI_ARGS is a \";\"-separated string of \"key=val\", so a \";\"\n\t\t\t\t// in either key or val would confuse plugins (or libraries)\n\t\t\t\t// that parse that string.\n\t\t\t\t// Pre-validating this here protects job authors from submitting\n\t\t\t\t// a job that will most likely error later on the client anyway.\n\t\t\t\tif strings.Contains(k, \";\") {\n\t\t\t\t\terr := fmt.Errorf(\"invalid ';' character in CNI arg key %q\", k)\n\t\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t\t}\n\t\t\t\tif strings.Contains(v, \";\") {\n\t\t\t\t\terr := fmt.Errorf(\"invalid ';' character in CNI arg value %q\", v)\n\t\t\t\t\tmErr.Errors = append(mErr.Errors, err)\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":7366,"sourceCodeEnd":7402,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/structs/structs.go#L7366-L7402","documentation":"Raised during job validation when the same CNI argument key is declared in the cni_args of more than one network resource in the same group. Nomad merges all network resources' args into the single CNI_ARGS string, so duplicate keys are ambiguous and rejected.","triggerScenarios":"Thrown at nomad/structs/structs.go:7384 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the duplicate key so each CNI arg appears in only one network resource","Merge the arguments into a single network block's cni_args map"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}