`COPY`/`ADD` JSON form is rewritten to shell form even when paths contain spaces
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start by locating the code that rewrites JSON-form COPY and ADD instructions, then check how it handles arguments containing whitespace. Use the reproduction Dockerfile in the issue to verify the formatter preserves the JSON form when paths contain spaces. Done means formatting no longer changes which source files or destinations the instructions name.
Written by the indexing model from the issue text.
Description
COPY and ADD in JSON (exec) form get rewritten to the space-separated form even when a path contains spaces. The JSON form exists for exactly that case, so the rewrite changes which files are copied and where.
Reproduce
FROM alpine
COPY ["my file.txt", "/app dir/"]
ADD ["src dir", "/opt/x y/"]
dockerfmt Dockerfile
Actual
FROM alpine
COPY my file.txt /app dir/
ADD src dir /opt/x y/
COPY my file.txt /app dir/ now names the sources my, file.txt and /app and the destination dir/. With a file called my file.txt in the context, the original builds and the output fails:
failed to compute cache key: failed to calculate checksum of ref ...: "/my": not found
Expected
Keep the JSON form when any argument contains whitespace, or don't convert COPY/ADD at all:
COPY ["my file.txt", "/app dir/"]
ADD ["src dir", "/opt/x y/"]
Reproduced with v0.5.4 and with main at a5868c2.
- Dominant language
- Go
- Stars
- 626
- Forks
- 23
- Avg merge
- 6d 23h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from reteps/dockerfmt
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
-
`MAINTAINER` to `LABEL` conversion does not escape embedded quotesPossibly taken @RyoKusnadi claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Legacy `ENV key value` with a multi-word value becomes an invalid `key=value`Possibly taken @RyoKusnadi claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
All issues in reteps/dockerfmt
Similar issues
-
Query cache: a failed cache page read leaves the set request's read lock held, so the scan hangsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
turbot/steampipe-plugin-sdk#986 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
router-for-me/CLIProxyAPI#7307 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
betterleaks/betterleaks#460 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
openmcp-project/service-provider-crossplane#330 ·
Maintainers usually reply within 1 day