{"record":{"id":"7ab7fc679cfa915a","repo":"docker/cli","slug":"invalid-field-key-key","errorCode":null,"errorMessage":"invalid field key {key}","messagePattern":"invalid field key (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/network.go","lineNumber":110,"sourceCode":"\t\t\t\tkey, val, err = parseDriverOpt(val)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tif netOpt.DriverOpts == nil {\n\t\t\t\t\tnetOpt.DriverOpts = make(map[string]string)\n\t\t\t\t}\n\t\t\t\tnetOpt.DriverOpts[key] = val\n\t\t\tcase gwPriorityOpt:\n\t\t\t\tnetOpt.GwPriority, err = strconv.Atoi(val)\n\t\t\t\tif err != nil {\n\t\t\t\t\tvar numErr *strconv.NumError\n\t\t\t\t\tif errors.As(err, &numErr) {\n\t\t\t\t\t\terr = numErr.Err\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"invalid gw-priority (%s): %w\", val, err)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn errors.New(\"invalid field key \" + key)\n\t\t\t}\n\t\t}\n\t\tif len(netOpt.Target) == 0 {\n\t\t\treturn errors.New(\"network name/id is not specified\")\n\t\t}\n\t} else {\n\t\tnetOpt.Target = value\n\t}\n\tn.options = append(n.options, netOpt)\n\treturn nil\n}\n\n// Type returns the type of this option\nfunc (*NetworkOpt) Type() string {\n\treturn \"network\"\n}\n\n// Value returns the networkopts","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/network.go#L92-L128","documentation":"Returned by NetworkOpt.Set (opts/network.go:110) in the long-syntax --network parser when a key does not match any known network option. Recognized keys are: name, alias, ip, ip6, mac-address, link-local-ip, driver-opt, and gw-priority. Any other key falls through to the default case and triggers this error with the offending key appended.","triggerScenarios":"A --network value in long syntax (key=value comma-separated) contains an unrecognized key. For example: '--network name=mynet,foo=bar' — 'foo' is not a valid network attachment option. Keys are lowercased before matching, so case differences don't cause this.","commonSituations":"Typo in an option name (e.g., 'aliases' instead of 'alias'), using an option that belongs to a different flag, or attempting to use an unsupported network configuration key.","solutions":["Check the key name against the allowed list: name, alias, ip, ip6, mac-address, link-local-ip, driver-opt, gw-priority.","Fix typos in the key name (e.g., 'aliases' → 'alias').","For multiple aliases, repeat the alias key: 'name=net,alias=a,alias=b'."],"exampleFix":"// before: unknown key\n// docker run --network name=mynet,aliases=web nginx\n\n// after: correct key name\n// docker run --network name=mynet,alias=web nginx","handlingStrategy":"validation","validationCode":"var validNetworkKeys = map[string]bool{\n    \"name\": true, \"alias\": true, \"ip\": true, \"ip6\": true,\n    \"mac-address\": true, \"link-local-ip\": true, \"driver-opt\": true,\n    \"gw-priority\": true,\n}\n\nfunc validateNetworkKeys(spec string) error {\n    for _, field := range strings.Split(spec, \",\") {\n        key, _, ok := strings.Cut(strings.ToLower(field), \"=\")\n        if ok && key != \"\" && !validNetworkKeys[key] {\n            return fmt.Errorf(\"unknown network key %q; valid: name, alias, ip, ip6, mac-address, link-local-ip, driver-opt, gw-priority\", key)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := networkOpt.Set(value); err != nil {\n    if strings.Contains(err.Error(), \"invalid field key\") {\n        return fmt.Errorf(\"unknown --network option; valid keys: name, alias, ip, ip6, mac-address, link-local-ip, driver-opt, gw-priority\")\n    }\n    return err\n}","preventionTips":["Reference the valid key list: name, alias, ip, ip6, mac-address, link-local-ip, driver-opt, gw-priority.","Use 'alias' (singular) not 'aliases'; repeat for multiple aliases.","Validate network option keys programmatically before calling NetworkOpt.Set."],"tags":["network","validation","cli-flag"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}