{"record":{"id":"3c092346d70a4c9e","repo":"docker/cli","slug":"bad-format-for-path-s","errorCode":null,"errorMessage":"bad format for path: %s","messagePattern":"bad format for path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/opts.go","lineNumber":1098,"sourceCode":"\t\t// Windows does validation entirely server-side\n\t\treturn val, nil\n\t}\n\treturn \"\", fmt.Errorf(\"unknown server OS: %s\", serverOS)\n}\n\n// validateLinuxPath is the implementation of validateDevice knowing that the\n// target server operating system is a Linux daemon.\n// It will make sure 'val' is in the form:\n//\n//\t[host-dir:]container-path[:mode]\n//\n// It also validates the device mode.\nfunc validateLinuxPath(val string, validator func(string) bool) (string, error) {\n\tvar containerPath string\n\tvar mode string\n\n\tif strings.Count(val, \":\") > 2 {\n\t\treturn val, fmt.Errorf(\"bad format for path: %s\", val)\n\t}\n\n\tsplit := strings.SplitN(val, \":\", 3)\n\tif split[0] == \"\" {\n\t\treturn val, fmt.Errorf(\"bad format for path: %s\", val)\n\t}\n\tswitch len(split) {\n\tcase 1:\n\t\tcontainerPath = split[0]\n\t\tval = path.Clean(containerPath)\n\tcase 2:\n\t\tif isValid := validator(split[1]); isValid {\n\t\t\tcontainerPath = split[0]\n\t\t\tmode = split[1]\n\t\t\tval = fmt.Sprintf(\"%s:%s\", path.Clean(containerPath), mode)\n\t\t} else {\n\t\t\tcontainerPath = split[1]\n\t\t\tval = fmt.Sprintf(\"%s:%s\", split[0], path.Clean(containerPath))","sourceCodeStart":1080,"sourceCodeEnd":1116,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/container/opts.go#L1080-L1116","documentation":"Thrown by validateLinuxPath when the device/path string contains more than two colons (strings.Count(val, \":\") > 2). The accepted format [host:]container[:mode] allows at most two colons.","triggerScenarios":"Passing a --device or path spec with three or more colons, e.g. '/a:/b:/c:/d'. This is checked before the split.","commonSituations":"Extra colon from a typo; concatenating host:container:mode with an additional stray separator; Windows paths leaking colons into Linux specs.","solutions":["Reduce to at most two colons: host:container:mode","Drop the extra segment"],"exampleFix":"# before\ndocker run --device /dev/x:/dev/y:rwm:extra ...\n# after\ndocker run --device /dev/x:/dev/y:rwm ...","handlingStrategy":"validation","validationCode":"func validPathColonCount(spec string) error {\n    if strings.Count(spec, \":\") > 2 {\n        return fmt.Errorf(\"path %q has too many colons\", spec)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate colon count together with device spec validation"],"tags":["docker","device","path","parse"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}