docker/cli · error
invalid field in config request
Error message
invalid field in config request: %s
What it means
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.
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.
Example fix
// before --config name=myconf,target=/etc/c // after --config source=myconf,target=/etc/c
Defensive patterns
Strategy: validation
Validate before calling
// Allowlist the recognized --config field keys before submission.
var configKeys = map[string]bool{"source": true, "src": true, "target": true, "uid": true, "gid": true, "mode": true}
for _, f := range strings.Split(cfgVal, ",") {
k, _, _ := strings.Cut(strings.ToLower(strings.TrimSpace(f)), "=")
if !configKeys[k] { return fmt.Errorf("unknown config key %q", k) }
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- invalid field ' ' must be a key=value pair
- invalid mode specified
- invalid field ' ' must be a key=value pair
- invalid field
- invalid protocol value
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/4024d48f8f272eaa.
Report an issue: GitHub.
Appendix: source
Thrown at opts/swarmopts/config.go:67
// TODO(thaJeztah): these options should not be case-insensitive.
switch strings.ToLower(key) {
case "source", "src":
options.ConfigName = val
case "target":
options.File.Name = val
case "uid":
options.File.UID = val
case "gid":
options.File.GID = val
case "mode":
m, err := strconv.ParseUint(val, 0, 32)
if err != nil {
return fmt.Errorf("invalid mode specified: %v", err)
}
options.File.Mode = os.FileMode(m)
default:
return fmt.Errorf("invalid field in config request: %s", key)
}
}
if options.ConfigName == "" {
return errors.New("source is required")
}
if options.File.Name == "" {
options.File.Name = options.ConfigName
}
o.values = append(o.values, options)
return nil
}
// Type returns the type of this option
func (*ConfigOpt) Type() string {
return "config"
}View on GitHub (pinned to 4f84911bfe)