{"record":{"id":"4024d48f8f272eaa","repo":"docker/cli","slug":"invalid-field-in-config-request-s","errorCode":null,"errorMessage":"invalid field in config request: %s","messagePattern":"invalid field in config request: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/swarmopts/config.go","lineNumber":67,"sourceCode":"\t\t// TODO(thaJeztah): these options should not be case-insensitive.\n\t\tswitch strings.ToLower(key) {\n\t\tcase \"source\", \"src\":\n\t\t\toptions.ConfigName = val\n\t\tcase \"target\":\n\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}","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/swarmopts/config.go#L49-L85","documentation":"Thrown by ConfigOpt.Set (config.go:67) when a config field key is not one of the recognized names: source/src, target, uid, gid, mode. Any other key (including typos or unsupported options) falls into the default switch case and is rejected with the offending key name.","triggerScenarios":"Passing `--config name=myconf` (should be `source=`), `--config path=/x`, `--config owner=root`, or any unrecognized key. The switch at line 50 lowercases the key, so case mismatches are tolerated but unknown keys hit default at line 66.","commonSituations":"Using the generic 'name' instead of 'source', inventing fields like 'path'/'owner'/'perms', or version skew where an older engine doesn't yet support a field you assumed existed.","solutions":["Use only the supported keys: source (or src), target, uid, gid, mode.","Check the Docker CLI/engine version — field sets differ across releases.","Spell the key exactly; although case-insensitive, the name must match the allowed set.","Consult `docker service create --help` for the current config syntax."],"exampleFix":"// before\n--config name=myconf,target=/etc/c\n// after\n--config source=myconf,target=/etc/c","handlingStrategy":"validation","validationCode":"// Allowlist the recognized --config field keys before submission.\nvar configKeys = map[string]bool{\"source\": true, \"src\": true, \"target\": true, \"uid\": true, \"gid\": true, \"mode\": true}\nfor _, f := range strings.Split(cfgVal, \",\") {\n    k, _, _ := strings.Cut(strings.ToLower(strings.TrimSpace(f)), \"=\")\n    if !configKeys[k] { return fmt.Errorf(\"unknown config key %q\", k) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 'source' (or 'src'), not 'name'.","Confirm the field set against your Docker CLI version's help.","Avoid inventing fields like 'path' or 'owner'.","Treat unknown-key errors as a version/spec mismatch to investigate."],"tags":["docker","swarm","config","validation","cli","secrets-configs"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}