apple / apple/container

[Bug]: `container cp` fails with "invalid path given" when a path contains a colon

Open Beginner friendly
#1,969 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
49.9k
Forks
1.8k
Avg merge
1d 20h
Merged PRs (30d)
22

Description

### Steps to reproduce

1. Create a file whose name contains a colon inside a container (common with ISO-8601 timestamps):
```
container run -d --name cpbox alpine \
sh -c 'echo hi > "/var/log/app-2026-07-20T10:30:00.log"; sleep 300'
```
2. Copy it out:
```
container cp "cpbox:/var/log/app-2026-07-20T10:30:00.log" ./out.log
```

### Current behavior

```
Error: invalid path given: cpbox:/var/log/app-2026-07-20T10:30:00.log
```

The file exists in the container (a colon is a legal character in a Linux path); only the reference parsing fails. Copying a file whose name contains no colon works.

### Expected behavior

The file is copied out — matching `docker cp`, which splits the `container:path` reference on the first colon only.

### Root cause

`Application.ContainerCopy.parsePathRef` splits the reference on *every* colon (`components(separatedBy: ":")`) and rejects anything that produces more than two parts. Any colon in the path (after the id) makes the parse fail. It should split on the first colon only, since a container id cannot contain a path separator.

### Environment

- container 1.1.0
- macOS 26.5 (Tahoe), Apple Silicon

Contributor guide

Open the contributing guide

Research direction

Start at Application.ContainerCopy.parsePathRef, which the report identifies as splitting container references on every colon. Reproduce the issue with the provided `container cp` command using a colon-containing path, then verify that the reference is split only at the first colon and the file is copied successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.