{"record":{"id":"b50c47268cb1585d","repo":"docker/cli","slug":"source-is-required","errorCode":null,"errorMessage":"source is required","messagePattern":"source is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/swarmopts/config.go","lineNumber":72,"sourceCode":"\t\t\toptions.File.Name = val\n\t\tcase \"uid\":\n\t\t\toptions.File.UID = val\n\t\tcase \"gid\":\n\t\t\toptions.File.GID = val\n\t\tcase \"mode\":\n\t\t\tm, err := strconv.ParseUint(val, 0, 32)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"invalid mode specified: %v\", err)\n\t\t\t}\n\n\t\t\toptions.File.Mode = os.FileMode(m)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid field in config request: %s\", key)\n\t\t}\n\t}\n\n\tif options.ConfigName == \"\" {\n\t\treturn errors.New(\"source is required\")\n\t}\n\tif options.File.Name == \"\" {\n\t\toptions.File.Name = options.ConfigName\n\t}\n\n\to.values = append(o.values, options)\n\treturn nil\n}\n\n// Type returns the type of this option\nfunc (*ConfigOpt) Type() string {\n\treturn \"config\"\n}\n\n// String returns a string repr of this option\nfunc (o *ConfigOpt) String() string {\n\tconfigs := make([]string, 0, len(o.values))\n\tfor _, config := range o.values {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/swarmopts/config.go#L54-L90","documentation":"Thrown by ConfigOpt.Set when parsing a --config request in key=value form but no source/src key was provided. A Swarm config reference requires a source config name to mount; the parser only validates this after consuming all fields, so a missing source is caught at the end. The simple short form (--config foo) auto-sets source and never triggers this.","triggerScenarios":"Passing --config target=/app.conf without a source=, or any key=value config spec omitting source/src.","commonSituations":"Mistakenly believing target alone identifies the config, or copy-pasting a partial spec that lost the source field.","solutions":["Add source=<configname> (or src=) to the --config spec.","Use the short form --config <configname> if no other overrides are needed.","Verify the config exists with docker config ls before referencing it."],"exampleFix":"// before\n--config target=/app.conf,uid=33\n// after\n--config source=appcfg,target=/app.conf,uid=33","handlingStrategy":"validation","validationCode":"hasSource := false\nfor _, f := range strings.Split(spec, \",\") {\n    k, _, _ := strings.Cut(strings.ToLower(f), \"=\")\n    if k == \"source\" || k == \"src\" {\n        hasSource = true\n    }\n}\nif !hasSource && !(len(strings.Split(spec, \",\")) == 1 && !strings.Contains(spec, \"=\")) {\n    return errors.New(\"config spec requires source=\")\n}","typeGuard":null,"tryCatchPattern":"if err := configOpt.Set(spec); err != nil {\n    return err\n}","preventionTips":["Default to the short form --config <name> when no overrides are needed.","Always include source= in key=value config specs."],"tags":["swarm","config","validation","opts"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}