Report an unreadable build context as permission denied, not a missing Dockerfile - #2093
Open
devops-thiago wants to merge 1 commit into
Open
Report an unreadable build context as permission denied, not a missing Dockerfile#2093devops-thiago wants to merge 1 commit into
devops-thiago wants to merge 1 commit into
Conversation
…erfile
`FileManager.fileExists` answers false both for a file that is not there and for
one the process may not look at, and `build` reported the first for both:
$ container build -t x:1 .
Error: dockerfile not found in context dir
with a Dockerfile sitting in that directory. Naming it with -f produced the
honest error — "you don't have permission to view it" — so the information was
available and thrown away by the earlier check. The message sends people to
inspect a build context that was never the problem.
Listing the directory separates the two cases: a denial fails, while a directory
that genuinely holds no Dockerfile lists fine. Only the default-resolution path
needs it; -f already surfaces the real error when it opens the file.
This is reachable whenever the CLI runs sandboxed, which it does when embedded
in an application bundle, and where reading the user's own project directory is
the ordinary case rather than an edge one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2089.
Type of Change
Motivation and Context
FileManager.fileExistsanswersfalseboth for a file that is absent and for one the process may not look at, andBuildCommand.validate()reported the first for both:The message sends the user to inspect a build context that was never the problem — naming the file with
-fshows the real permission error was available and discarded by the earlier check. Reproduction and details in #2089.Description
When default Dockerfile resolution fails, the context directory is listed once: a denial throws
cannot read context dir <path>: permission denied, while a directory that genuinely holds no Dockerfile lists fine and keeps the existing message. Only the default-resolution path changes;-falready surfaces the real error when it opens the file.Testing
swift buildclean on this branch at abff418.Error: cannot read context dir /tmp/ctxtest: permission denied— verified against the built CLI from this branch.dockerfile not found in context dir.