{"record":{"id":"cb9a941580c3fe13","repo":"docker/cli","slug":"invalid-value-for-s-in-s-value-should-not-h","errorCode":null,"errorMessage":"invalid value for '%s' in '%s': value should not have whitespace","messagePattern":"invalid value for '(.+?)' in '(.+?)': value should not have whitespace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/mount.go","lineNumber":51,"sourceCode":"\t\treturn err\n\t}\n\n\tmount := mounttypes.Mount{\n\t\tType: mounttypes.TypeVolume, // default to volume mounts\n\t}\n\n\tfor _, field := range fields {\n\t\tkey, val, hasValue := strings.Cut(field, \"=\")\n\t\tif k := strings.TrimSpace(key); k != key {\n\t\t\treturn fmt.Errorf(\"invalid option '%s' in '%s': option should not have whitespace\", k, field)\n\t\t}\n\t\tif hasValue {\n\t\t\tv := strings.TrimSpace(val)\n\t\t\tif v == \"\" {\n\t\t\t\treturn fmt.Errorf(\"invalid value for '%s': value is empty\", key)\n\t\t\t}\n\t\t\tif v != val {\n\t\t\t\treturn fmt.Errorf(\"invalid value for '%s' in '%s': value should not have whitespace\", key, field)\n\t\t\t}\n\t\t}\n\n\t\t// TODO(thaJeztah): these options should not be case-insensitive.\n\t\tkey = strings.ToLower(key)\n\n\t\tif !hasValue {\n\t\t\tswitch key {\n\t\t\tcase \"readonly\", \"ro\", \"volume-nocopy\", \"bind-nonrecursive\", \"bind-create-src\":\n\t\t\t\t// boolean values\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"invalid field '%s' must be a key=value pair\", field)\n\t\t\t}\n\t\t}\n\n\t\tswitch key {\n\t\tcase \"type\":\n\t\t\tmount.Type = mounttypes.Type(strings.ToLower(val))","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/mount.go#L33-L69","documentation":"Returned by MountOpt.Set (opts/mount.go:51) when an option value has leading or trailing whitespace. The parser trims the value and compares against the raw value; if they differ it rejects the field, since embedded padding around values is almost always a mistake and would silently corrupt paths/names.","triggerScenarios":"A --mount CSV field whose value has surrounding spaces or tabs, e.g. `source= foo`, `target=/data `, or a value embedded as ` source = /data `. Keys are checked separately (error 623); this is specifically the value side.","commonSituations":"Spaces around '=' for readability, tabs in generated YAML/CSV, or quoted shell values that retained padding.","solutions":["Trim spaces from values: source=/var/data (no padding).","Avoid `key = value` style; use key=value with no surrounding whitespace.","If whitespace inside the value is genuinely intended (e.g. a label), note this parser does not allow leading/trailing whitespace — sanitize first.","Regenerate compose/templated mount strings without spaces around '='."],"exampleFix":"// before\n--mount \"type=volume,source= mydata ,target=/data\"\n\n// after\n--mount \"type=volume,source=mydata,target=/data\"","handlingStrategy":"validation","validationCode":"// rejectValueWhitespace ensures no value has surrounding whitespace.\nfunc rejectValueWhitespace(spec string) error {\n    r := csv.NewReader(strings.NewReader(spec))\n    fields, err := r.Read()\n    if err != nil {\n        return err\n    }\n    for _, f := range fields {\n        _, v, has := strings.Cut(f, \"=\")\n        if has && v != strings.TrimSpace(v) {\n            return fmt.Errorf(\"value %q has surrounding whitespace\", v)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := m.Set(spec); err != nil {\n    return fmt.Errorf(\"mount %q: %w\", spec, err)\n}","preventionTips":["Generate mounts from structured fields; never string-format with padding.","Trim generated values explicitly before joining.","Add a unit test that asserts emitted specs round-trip through MountOpt.Set."],"tags":["mount","docker","csv","whitespace","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}