{"record":{"id":"4f3810529093bf8c","repo":"docker/cli","slug":"error-reading-content-from-q-v","errorCode":null,"errorMessage":"error reading content from %q: %v","messagePattern":"error reading content from %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/config/create.go","lineNumber":73,"sourceCode":"\t\t\t}\n\t\t},\n\t\tDisableFlagsInUseLine: true,\n\t}\n\tflags := cmd.Flags()\n\tflags.VarP(&createOpts.labels, \"label\", \"l\", \"Config labels\")\n\tflags.StringVar(&createOpts.templateDriver, \"template-driver\", \"\", \"Template driver\")\n\t_ = flags.SetAnnotation(\"template-driver\", \"version\", []string{\"1.37\"})\n\n\treturn cmd\n}\n\n// runCreate creates a config with the given options.\nfunc runCreate(ctx context.Context, dockerCLI command.Cli, options createOptions) error {\n\tapiClient := dockerCLI.Client()\n\n\tconfigData, err := readConfigData(dockerCLI.In(), options.file)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error reading content from %q: %v\", options.file, err)\n\t}\n\n\tspec := swarm.ConfigSpec{\n\t\tAnnotations: swarm.Annotations{\n\t\t\tName:   options.name,\n\t\t\tLabels: opts.ConvertKVStringsToMap(options.labels.GetSlice()),\n\t\t},\n\t\tData: configData,\n\t}\n\tif options.templateDriver != \"\" {\n\t\tspec.Templating = &swarm.Driver{\n\t\t\tName: options.templateDriver,\n\t\t}\n\t}\n\tr, err := apiClient.ConfigCreate(ctx, client.ConfigCreateOptions{\n\t\tSpec: spec,\n\t})\n\tif err != nil {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/cli/command/config/create.go#L55-L91","documentation":"Returned by runCreate() for `docker config create` when readConfigData() fails to read the data source (cli/command/config/create.go:71-74). readConfigData handles stdin ('-'), empty path, and a file path; this top-level wrapper reports the user-supplied file argument verbatim. The underlying cause is the inner error from readConfigData (file open failure, read failure, or empty-data error for the named file).","triggerScenarios":"Running `docker config create NAME <file>` where the file cannot be opened, read, or is empty. The error is propagated from readConfigData and re-wrapped with the original %q file argument the user passed.","commonSituations":"Wrong path / typo, file does not exist, permission denied, file is a directory, or an empty file. Also when a tilde or shell variable did not expand (literal passed to the CLI).","solutions":["Verify the path exists and is readable: ls -l <file>.","Ensure the file is non-empty (see errors 270) and is a regular file, not a directory.","Expand shell variables/tildes before passing the argument, or use an absolute path.","Use '-' to stream data via stdin if the source is a pipe."],"exampleFix":"# before\ndocker config create mycfg ~/missing.txt   # ~ not expanded / file missing\n# after\ndocker config create mycfg \"$HOME/config.txt\"","handlingStrategy":"validation","validationCode":"// Pre-flight check for the config file argument.\nfunc validateConfigSource(path string) error {\n    if path == \"\" { return errors.New(\"config file is required\") }\n    if path == \"-\" { return nil }\n    fi, err := os.Stat(path)\n    if err != nil { return err }\n    if fi.IsDir() { return fmt.Errorf(\"%s is a directory\", path) }\n    if fi.Size() == 0 { return fmt.Errorf(\"%s is empty\", path) }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve the path to absolute and stat it before invoking docker config create.","Use test -f and test -s in shell wrappers to guard against missing/empty files."],"tags":["config","swarm","filesystem","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}