{"record":{"id":"97a60bf27e0ca042","repo":"docker/cli","slug":"empty-section-between-colons","errorCode":null,"errorMessage":"empty section between colons","messagePattern":"empty section between colons","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/volumespec/volumespec.go","lineNumber":60,"sourceCode":"\t\t\tbuffer = buffer[:0] // reset, but reuse capacity\n\t\tdefault:\n\t\t\tbuffer = append(buffer, char)\n\t\t}\n\t}\n\n\tpopulateType(&volume)\n\treturn volume, nil\n}\n\nfunc isWindowsDrive(buffer []rune, char rune) bool {\n\treturn char == ':' && len(buffer) == 1 && unicode.IsLetter(buffer[0])\n}\n\nfunc populateFieldFromBuffer(char rune, buffer []rune, volume *VolumeConfig) error {\n\tstrBuffer := string(buffer)\n\tswitch {\n\tcase len(buffer) == 0:\n\t\treturn errors.New(\"empty section between colons\")\n\t// Anonymous volume\n\tcase volume.Source == \"\" && char == endOfSpec:\n\t\tvolume.Target = strBuffer\n\t\treturn nil\n\tcase volume.Source == \"\":\n\t\tvolume.Source = strBuffer\n\t\treturn nil\n\tcase volume.Target == \"\":\n\t\tvolume.Target = strBuffer\n\t\treturn nil\n\tcase char == ':':\n\t\treturn errors.New(\"too many colons\")\n\t}\n\tfor option := range strings.SplitSeq(strBuffer, \",\") {\n\t\tswitch option {\n\t\tcase \"ro\":\n\t\t\tvolume.ReadOnly = true\n\t\tcase \"rw\":","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/internal/volumespec/volumespec.go#L42-L78","documentation":"Returned by populateFieldFromBuffer (internal/volumespec/volumespec.go:60) during Parse when a colon (or end-of-spec marker) is encountered but the character buffer is empty. This means two colons appear back-to-back (::), or the spec begins or ends with a colon, producing an empty segment where a path/name is expected.","triggerScenarios":"volumespec.Parse is called with a spec containing '::' (e.g., '/foo::/bar'), a leading colon (':/bar'), or a trailing colon ('/foo:'). The parser accumulates characters into a buffer; when it hits a delimiter with an empty buffer, this error fires.","commonSituations":"Typo producing double colons in a volume mount spec, copy-paste error, malformed compose volume string, accidental leading/trailing colon from string concatenation.","solutions":["Inspect the volume spec for double colons (::) or leading/trailing colons and remove them.","Validate the spec format: a volume spec should have at most two colons separating source, target, and options — each segment must be non-empty."],"exampleFix":"// before: double colon in spec\n// docker run -v /foo::/bar nginx\n\n// after: single colon\n// docker run -v /foo:/bar nginx","handlingStrategy":"validation","validationCode":"func validateVolumeSpecFormat(spec string) error {\n    if strings.HasPrefix(spec, \":\") || strings.HasSuffix(spec, \":\") {\n        return fmt.Errorf(\"volume spec must not start or end with a colon: %s\", spec)\n    }\n    if strings.Contains(spec, \"::\") {\n        return fmt.Errorf(\"volume spec must not contain empty segments (::): %s\", spec)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"vol, err := volumespec.Parse(spec)\nif err != nil {\n    if strings.Contains(err.Error(), \"empty section between colons\") {\n        return fmt.Errorf(\"malformed volume spec %q: remove empty segments (::)\", spec)\n    }\n    return err\n}","preventionTips":["Avoid double colons (::) in volume mount specs.","Ensure volume specs don't start or end with a colon.","Validate volume strings programmatically before passing to Parse."],"tags":["volume","validation","parse","mount"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}