{"id":"8eea32b8f23a50f3","repo":"docker/cli","slug":"invalid-output-path-q-must-be-a-directory-or-a-r","errorCode":null,"errorMessage":"invalid output path: %q must be a directory or a regular file: %w","messagePattern":"invalid output path: %q must be a directory or a regular file: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/utils.go","lineNumber":81,"sourceCode":"\tdir := filepath.Dir(filepath.Clean(path))\n\tif dir != \"\" && dir != \".\" {\n\t\tif _, err := os.Stat(dir); os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"invalid output path: directory %q does not exist\", dir)\n\t\t}\n\t}\n\t// check whether `path` points to a regular file\n\t// (if the path exists and doesn't point to a directory)\n\tif fileInfo, err := os.Stat(path); !os.IsNotExist(err) {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif fileInfo.Mode().IsDir() || fileInfo.Mode().IsRegular() {\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := ValidateOutputPathFileMode(fileInfo.Mode()); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid output path: %q must be a directory or a regular file: %w\", path, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// ValidateOutputPathFileMode validates the output paths of the \"docker cp\" command\n// and serves as a helper to [ValidateOutputPath]\nfunc ValidateOutputPathFileMode(fileMode os.FileMode) error {\n\tswitch {\n\tcase fileMode&os.ModeDevice != 0:\n\t\treturn errors.New(\"got a device\")\n\tcase fileMode&os.ModeIrregular != 0:\n\t\treturn errors.New(\"got an irregular file\")\n\t}\n\treturn nil\n}\n\nfunc invalidParameter(err error) error {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/utils.go#L63-L99","documentation":"Error \"invalid output path: %q must be a directory or a regular file: %w\" thrown in docker/cli.","triggerScenarios":"Thrown at cli/command/utils.go:81 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}