{"record":{"id":"b1b705fccaf23bb6","repo":"docker/cli","slug":"invalid-key-value-pair-format-in-driver-options-b1b705","errorCode":null,"errorMessage":"invalid key value pair format in driver options","messagePattern":"invalid key value pair format in driver options","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/network.go","lineNumber":153,"sourceCode":"\treturn \"\"\n}\n\n// NetworkMode return the network mode for the network option\nfunc (n *NetworkOpt) NetworkMode() string {\n\tnetworkIDOrName := \"default\"\n\tnetOptVal := n.Value()\n\tif len(netOptVal) > 0 {\n\t\tnetworkIDOrName = netOptVal[0].Target\n\t}\n\treturn networkIDOrName\n}\n\nfunc parseDriverOpt(driverOpt string) (string, string, error) {\n\t// TODO(thaJeztah): these options should not be case-insensitive.\n\t// TODO(thaJeztah): should value be converted to lowercase as well, or only the key?\n\tkey, value, ok := strings.Cut(strings.ToLower(driverOpt), \"=\")\n\tif !ok || key == \"\" {\n\t\treturn \"\", \"\", errors.New(\"invalid key value pair format in driver options\")\n\t}\n\tkey = strings.TrimSpace(key)\n\tvalue = strings.TrimSpace(value)\n\treturn key, value, nil\n}\n","sourceCodeStart":135,"sourceCodeEnd":159,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/network.go#L135-L159","documentation":"Returned by parseDriverOpt (opts/network.go:153) when a 'driver-opt' value in the --network long syntax does not contain an '=' separator or has an empty key after lowercasing. Driver options must be specified as 'driver-opt=key=value' where the inner key=value is the driver-specific option.","triggerScenarios":"A --network value contains 'driver-opt=<val>' where <val> lacks '=' (e.g., 'driver-opt=debug') or starts with '=' (e.g., 'driver-opt==value' producing empty key). parseDriverOpt uses strings.Cut on '=' and checks that both ok is true and key is non-empty.","commonSituations":"Missing the value part of a driver option (e.g., 'driver-opt=com.docker.network.bridge.enable_icc' without '=true'), typo omitting '=', or misunderstanding that driver-opt requires an inner key=value pair.","solutions":["Format driver-opt as 'driver-opt=key=value', e.g., 'driver-opt=com.docker.network.bridge.enable_icc=true'.","Ensure the inner key (before the inner '=') is non-empty."],"exampleFix":"// before: missing value in driver-opt\n// docker run --network name=mynet,driver-opt=com.docker.network.bridge.enable_icc nginx\n\n// after: include key=value\n// docker run --network name=mynet,driver-opt=com.docker.network.bridge.enable_icc=true nginx","handlingStrategy":"validation","validationCode":"func validateDriverOpt(spec string) error {\n    for _, field := range strings.Split(spec, \",\") {\n        key, val, ok := strings.Cut(strings.ToLower(field), \"=\")\n        if ok && key == \"driver-opt\" {\n            innerKey, _, innerOK := strings.Cut(val, \"=\")\n            if !innerOK || innerKey == \"\" {\n                return fmt.Errorf(\"driver-opt requires key=value format: %s\", val)\n            }\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := networkOpt.Set(value); err != nil {\n    if err.Error() == \"invalid key value pair format in driver options\" {\n        return fmt.Errorf(\"format driver-opt as 'driver-opt=key=value', e.g., driver-opt=com.docker.network.bridge.enable_icc=true\")\n    }\n    return err\n}","preventionTips":["Format driver-opt as 'driver-opt=key=value' with an inner '=' separator.","Ensure the inner key (before '=') is non-empty.","Validate driver-opt values before passing to NetworkOpt.Set."],"tags":["network","driver","validation","cli-flag"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}