{"record":{"id":"cedf4e10651bed74","repo":"docker/cli","slug":"invalid-key-value-pair-format-in-driver-options","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":"cli/command/network/connect.go","lineNumber":95,"sourceCode":"\t\t\t\tLinkLocalIPs: toNetipAddrSlice(options.linklocalips),\n\t\t\t},\n\t\t\tLinks:      options.links.GetSlice(),\n\t\t\tAliases:    options.aliases,\n\t\t\tDriverOpts: driverOpts,\n\t\t\tGwPriority: options.gwPriority,\n\t\t},\n\t})\n\treturn err\n}\n\nfunc convertDriverOpt(options []string) (map[string]string, error) {\n\tdriverOpt := make(map[string]string)\n\tfor _, opt := range options {\n\t\tk, v, ok := strings.Cut(opt, \"=\")\n\t\t// TODO(thaJeztah): we should probably not accept whitespace here (both for key and value).\n\t\tk = strings.TrimSpace(k)\n\t\tif !ok || k == \"\" {\n\t\t\treturn nil, errors.New(\"invalid key/value pair format in driver options\")\n\t\t}\n\t\tdriverOpt[k] = strings.TrimSpace(v)\n\t}\n\treturn driverOpt, nil\n}\n\nfunc toNetipAddrSlice(ips []net.IP) []netip.Addr {\n\tif len(ips) == 0 {\n\t\treturn nil\n\t}\n\tnetIPs := make([]netip.Addr, 0, len(ips))\n\tfor _, ip := range ips {\n\t\tnetIPs = append(netIPs, toNetipAddr(ip))\n\t}\n\treturn netIPs\n}\n\nfunc toNetipAddr(ip net.IP) netip.Addr {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/network/connect.go#L77-L113","documentation":"convertDriverOpt() parses each --driver-opt value as key=value via strings.Cut. If the value has no \"=\" separator, or the key is empty after TrimSpace, the pair is malformed and the whole parse aborts, returning this error before the NetworkConnect API is called.","triggerScenarios":"`docker network connect --driver-opt foo mynet myc` (no =), or `--driver-opt =val` (empty key), or a value like `justakey`.","commonSituations":"Typos; forgetting the = separator; copying syntax from a different tool that uses spaces or colons; trailing flags concatenated incorrectly.","solutions":["Use key=value format: `--driver-opt key=value`","Quote the pair if the value contains special characters","Verify each --driver-opt contains exactly one = with a non-empty key"],"exampleFix":"// before\ndocker network connect --driver-opt foo mynet myc\n// after\ndocker network connect --driver-opt foo=bar mynet myc","handlingStrategy":"validation","validationCode":"for _, opt := range driverOpts {\n    k, v, ok := strings.Cut(opt, \"=\")\n    if !ok || strings.TrimSpace(k) == \"\" {\n        return fmt.Errorf(\"invalid driver-opt %q: expected key=value\", opt)\n    }\n    _ = v\n}","typeGuard":"func isValidDriverOpt(s string) bool {\n    k, _, ok := strings.Cut(s, \"=\")\n    return ok && strings.TrimSpace(k) != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always format --driver-opt as key=value (no spaces around = unless intended)","Validate each driver-opt string before invoking network connect","Quote values containing special characters and double-check the separator"],"tags":["network","cli","config","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}