{"record":{"id":"a1484988d9c32fe4","repo":"docker/cli","slug":"error-reading-from-s-w","errorCode":null,"errorMessage":"error reading from %s: %w","messagePattern":"error reading from (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/config/create.go","lineNumber":133,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"error reading from STDIN: %w\", err)\n\t\t}\n\t\tif len(data) == 0 {\n\t\t\treturn nil, errors.New(\"error reading from STDIN: data is empty\")\n\t\t}\n\t\treturn data, nil\n\tcase \"\":\n\t\treturn nil, errors.New(\"config file is required\")\n\tdefault:\n\t\t// Open file with [FILE_FLAG_SEQUENTIAL_SCAN] on Windows, which\n\t\t// prevents Windows from aggressively caching it. We expect this\n\t\t// file to be only read once. Given that this is expected to be\n\t\t// a small file, this may not be a significant optimization, so\n\t\t// we could choose to omit this, and use a regular [os.Open].\n\t\t//\n\t\t// [FILE_FLAG_SEQUENTIAL_SCAN]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN\n\t\tf, err := sequential.Open(fileName)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading from %s: %w\", fileName, err)\n\t\t}\n\t\tdefer f.Close()\n\t\tdata, err := io.ReadAll(io.LimitReader(f, 2*maxConfigSize))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error reading from %s: %w\", fileName, err)\n\t\t}\n\t\tif len(data) == 0 {\n\t\t\treturn nil, fmt.Errorf(\"error reading from %s: data is empty\", fileName)\n\t\t}\n\t\treturn data, nil\n\t}\n}\n","sourceCodeStart":115,"sourceCodeEnd":146,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/config/create.go#L115-L146","documentation":"Returned by readConfigData() when opening the config file fails (cli/command/config/create.go:131-134). It uses sequential.Open (FILE_FLAG_SEQUENTIAL_SCAN on Windows) and wraps the os.Open error with the file path. Typical causes map to os.PathError: ENOENT (not found), EACCES (permission denied), or EISDIR (path is a directory).","triggerScenarios":"Running `docker config create NAME <file>` where sequential.Open(fileName) returns an error: file does not exist, no read permission, or the path resolves to a directory.","commonSituations":"Typo in path, relative path evaluated from an unexpected working directory, permission denied, or pointing at a directory instead of a file.","solutions":["Confirm the file exists and is a regular file: test -f <file>.","Fix permissions so the current user can read it: chmod u+r <file>.","Use an absolute path or ensure the correct working directory.","If the source is a directory, tar/encode it first or pick the actual file."],"exampleFix":"# before\ndocker config create mycfg ./config   # ./config is a directory\n# after\ndocker config create mycfg ./config/app.conf","handlingStrategy":"validation","validationCode":"func validateConfigFile(path string) error {\n    fi, err := os.Stat(path)\n    if err != nil { return fmt.Errorf(\"cannot open %s: %w\", path, err) }\n    if fi.IsDir() { return fmt.Errorf(\"%s is a directory\", path) }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an absolute, stat-checked path.","Run test -f <path> in wrappers to fail fast on missing/dir sources."],"tags":["config","swarm","filesystem","permissions"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}