fix: clear error for missing .dockerignore in with_dockerignore#1184
Open
EngHabu wants to merge 1 commit into
Open
fix: clear error for missing .dockerignore in with_dockerignore#1184EngHabu wants to merge 1 commit into
EngHabu wants to merge 1 commit into
Conversation
pingsutw
reviewed
Jun 10, 2026
Comment on lines
+1188
to
+1192
| if not resolved.is_file(): | ||
| raise flyte.errors.ImageBuildError( | ||
| f"The .dockerignore file specified via with_dockerignore() was not found at '{path}'. " | ||
| f"Ensure the path points to an existing file." | ||
| ) |
Member
There was a problem hiding this comment.
I think we don't need the check here since the dockerignore file may not exist in the image at runtime
43768ec to
52b3b68
Compare
52b3b68 to
5f92cbd
Compare
A non-existent path passed to Image.with_dockerignore() surfaced as a raw FileNotFoundError at build time (often because a relative path like '.dockerignore' was resolved against the builder's working directory rather than where the image was defined). Resolve the path to an absolute path at definition time and raise a clear ImageBuildError (a RuntimeUserError) when the file is missing, in both the remote and local docker build paths. fixes FLYTE-SDK-4Z Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
5f92cbd to
ad604f8
Compare
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.
Problem
Image.with_dockerignore(path)stored the path as-is and copied it into the build context with a bareshutil.copy(layer.path, context_path)in both the remote and local docker build paths. When the path was relative (e.g..dockerignore), the remote builder — which runs from a different working directory than where the image was defined — could not find it and raised a raw, uninformativeFileNotFoundErrorthat leaked to Sentry.Sentry: FLYTE-SDK-4Z (
FileNotFoundError: [Errno 2] No such file or directory: '.dockerignore', observed on the latest release 2.4.4).Fix
with_dockerignore()now resolves the path to an absolute path at definition time, so the file remains locatable at build time regardless of the builder's working directory.ImageBuildError(aRuntimeUserError, which is filtered from Sentry) with an actionable message, instead of a rawFileNotFoundError.remote_builder._get_layers_protoanddocker_builder.DockerIgnoreHandler.handle).Tests
Added two tests in
tests/flyte/test_image.py:.dockerignorepath raisesImageBuildErrorAll existing dockerignore tests still pass (
9 passed), plustest_docker_builder.py(38 passed).fixes FLYTE-SDK-4Z
🤖 Generated with Claude Code