--dockerfile with a missing file or a folder prints a raw [Errno 2] / [Errno 21] error

Open Beginner friendly
#727 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, python
Domain
cli

Research direction

Start with read_image() in src/wheelgap/cli.py, which calls read_dockerfile() in src/wheelgap/dockerfile.py and currently lets the raw OSError escape. Add an is_file()/exists() check before the read that raises DockerfileError with the message naming the flag and, for a folder, suggesting docker/Dockerfile. Tests go in tests/test_cli.py: a missing path and a folder should each exit 2, and the --json error keys (message, type) should stay the same. Done when those tests fail on main and pass with the change, and the CHANGELOG.md Unreleased bullet is added.

Written by the indexing model from the issue text.

Description

bug good first issue

A missing input file gets a plain message (nope.txt: no such file), but a --dockerfile path that doesn't exist, or is a folder, prints Python's raw OSError:

Reproduced with the released uvx wheelgap==0.14.0 (same code on main):

$ uvx wheelgap==0.14.0 nope.txt -p 3.13 -t linux-x86_64
wheelgap: error: nope.txt: no such file
$ uvx wheelgap==0.14.0 --dockerfile nope
wheelgap: error: [Errno 2] No such file or directory: 'nope'
$ mkdir docker && uvx wheelgap==0.14.0 --dockerfile docker
wheelgap: error: [Errno 21] Is a directory: 'docker'
$ uvx wheelgap==0.14.0 --dockerfile nope --json
{"error": {"message": "[Errno 2] No such file or directory: 'nope'", "type": "FileNotFoundError"}}

The message doesn't name the flag, and for a folder it doesn't suggest the likely fix (--dockerfile docker/Dockerfile).

Where

read_dockerfile() in src/wheelgap/dockerfile.py reads the file with path.read_bytes() and only catches UnicodeDecodeError. read_image() in src/wheelgap/cli.py calls it. The MCP tool check_dockerfile (src/wheelgap/mcp.py) and suggest_targets.py call it too, so check that whatever you change still reads well there.

What to do

  • Raise DockerfileError for a path that doesn't exist (--dockerfile nope: no such file) and for a folder (--dockerfile docker: is a folder; pass the Dockerfile in it, e.g. docker/Dockerfile). Simplest: check in cli.py before read_dockerfile(), as --dockerfile-context already does with is_dir().
  • Other OSErrors (a permission error) can stay as they are.

Done when

  • Tests in tests/test_cli.py: a missing path and a folder each exit 2 with the new message, and with --json the error object has the same keys (message, type). They fail on main.
  • No network in the tests.
  • One CHANGELOG.md bullet under ## Unreleased.
  • --json keys are only added, never renamed or removed.
Dominant language
Python
Stars
0
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from patrickballard/wheelgap

All issues in patrickballard/wheelgap

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.