{"record":{"id":"a4642494368e6395","repo":"docker/cli","slug":"invalid-value-for-s-value-is-empty","errorCode":null,"errorMessage":"invalid value for '%s': value is empty","messagePattern":"invalid value for '(.+?)': value is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/mount.go","lineNumber":48,"sourceCode":"\tcsvReader := csv.NewReader(strings.NewReader(value))\n\tfields, err := csvReader.Read()\n\tif err != nil {\n\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","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/mount.go#L30-L66","documentation":"Returned by MountOpt.Set (opts/mount.go:48) when an option is written as `key=` but the value (after TrimSpace) is empty. The parser requires every key=value option to carry a non-blank value; bare toggles must instead omit the '=' entirely (handled by the boolean-option branch).","triggerScenarios":"Passing `source=`, `target=`, `type=`, `volume-driver=` etc. in a --mount CSV — any field that has '=' followed by nothing or only whitespace.","commonSituations":"Templating/compose generation that emits `key=$VAR` with VAR unset, a trailing `=` typo, or copy-paste where the value was dropped.","solutions":["Supply a concrete value: source=/var/data.","If the option is a boolean toggle (readonly, ro, volume-nocopy, bind-create-src), drop the '=' entirely instead of writing readonly=.","Ensure shell/env variables used to fill values are non-empty at evaluation time.","Remove the field if it is not needed."],"exampleFix":"// before\n--mount \"type=volume,source=,target=/data\"\n\n// after\n--mount \"type=volume,source=mydata,target=/data\"","handlingStrategy":"validation","validationCode":"// requireNonEmpty checks key=value options carry a value before MountOpt.Set.\nfunc requireNonEmpty(spec string) error {\n    r := csv.NewReader(strings.NewReader(spec))\n    fields, err := r.Read()\n    if err != nil {\n        return err\n    }\n    boolToggles := map[string]bool{\"readonly\": true, \"ro\": true, \"volume-nocopy\": true, \"bind-nonrecursive\": true, \"bind-create-src\": true}\n    for _, f := range fields {\n        k, v, has := strings.Cut(f, \"=\")\n        if has && strings.TrimSpace(v) == \"\" && !boolToggles[strings.ToLower(strings.TrimSpace(k))] {\n            return fmt.Errorf(\"option %q has empty value\", k)\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":["Default unset template variables to a sentinel and fail loudly instead of emitting key=.","For booleans, omit the '=' rather than writing toggle=.","Validate generated mount strings against the known option set."],"tags":["mount","docker","csv","empty-value","validation"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}