Skip to content

format: read a volume named with a single letter as a named volume - #972

Merged
ndeloof merged 1 commit into
compose-spec:mainfrom
ndeloof:parse-volume-single-letter
Oct 25, 2026
Merged

ndeloof merged 1 commit into
compose-spec:mainfrom
ndeloof:parse-volume-single-letter

Conversation

@ndeloof

@ndeloof ndeloof commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

What this PR does, in one sentence

A volume named with a single letter (a:/data) is read as a named volume again, instead of being mistaken for a Windows drive.

Context

ParseVolume takes a single letter followed by a colon for a Windows drive, whatever the platform. A Compose file such as

services:
  app:
    image: alpine
    volumes:
      - a:/data
      - b:/logs:ro
volumes:
  a:
  b:

loads, on Linux and macOS too, as an anonymous volume mounted at a:/data, and b:/logs:ro as a bind mount of b:/logs on a target named ro. Docker then rejects the project, although a one-letter volume name is valid. The same reading made ServiceVolumeConfig.String(), documented as parseable back, unable to round trip as soon as a source or a target tied in one letter (x:y:ro, /data:a:ro).

What the PR brings

A single letter ends a Windows drive only when a path separator follows the colon:

  • C:\data:/data is a bind mount of the drive, as before;
  • C:/data:/data, C:/data:/data:ro and C:/data:d:\data are too: a target after the path, or more sections, can only be a bind mount from the drive;
  • a:/data, a:/data:ro and a:b are a named volume a, as the Linux and macOS Docker parsers read them.

One form is inherently ambiguous without knowing the platform: a bare C:/data, an anonymous volume on a Windows container path, now reads as the volume C mounted at /data (with a backslash, C:\data is unchanged).

The short syntax is covered by a conformance test in loader/tests and by table tests in format, and FuzzParseVolume no longer skips the volumes with a single letter source or target.

🤖 Generated with Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Windows bind mounts with unresolved target expressions can be misclassified as named volumes, silently losing the intended target.

1 open issue
What changed in this PR

This PR updates Compose short-syntax volume parsing so single-letter names are recognized as named volumes while preserving common Windows drive-path forms.

Changes:

  • Distinguishes single-letter volume names from Windows drive paths.
  • Adds parser and loader regression coverage.
  • Expands fuzz round-trip checks to include single-letter sources and targets.
File Description
loader/​tests/​volumes_test.go Adds service and job conformance cases for volume names and Windows paths.
format/​volume.go Adds drive-path and named-volume disambiguation logic.
format/​volume_test.go Covers single-letter names, targets, and Windows drive forms.
format/​volume_fuzz_test.go Removes single-letter exclusions and adds regression seeds.

Review effort: Balanced

Comment thread format/volume.go Resolved
A single letter followed by a colon was always taken for a Windows drive,
so `a:/data` became an anonymous volume at `a:/data` and `a:/data:ro` a
bind mount of `a:/data` on `ro`, on any platform. The letter is now a drive
only when a path separator follows: always for a backslash, and for a slash
unless the spec reads as a named volume (a single section after the path, not
a target). `C:\data:/data` and `C:/data:/data` keep binding the drive.

The fuzzer no longer skips the volumes with a single letter source or target.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof
ndeloof force-pushed the parse-volume-single-letter branch from 2ee2f55 to 7bd8c75 Compare October 25, 2026 08:45
@ndeloof
ndeloof requested a balanced review from Copilot October 25, 2026 08:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no unresolved blocking issues, and the previously reported unresolved-target regression is fixed with explicit coverage.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@ndeloof
ndeloof merged commit 9b245dd into compose-spec:main Oct 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants