<#1184 fix: clear error for missing .dockerignore ...
# flyte-github
a
#1184 fix: clear error for missing .dockerignore in with_dockerignore Pull request opened by EngHabu Problem
Image.with_dockerignore(path)
stored the path as-is and copied it into the build context with a bare
shutil.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, uninformative
FileNotFoundError
that 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. • If the file does not exist, it raises a clear
ImageBuildError
(a
RuntimeUserError
, which is filtered from Sentry) with an actionable message, instead of a raw
FileNotFoundError
. • Added the same defensive guard at both build-time copy sites (
remote_builder._get_layers_proto
and
docker_builder.DockerIgnoreHandler.handle
). Tests Added two tests in `tests/flyte/test_image.py`: • a missing
.dockerignore
path raises
ImageBuildError
• a relative path is resolved to an absolute, still-locatable path All existing dockerignore tests still pass (
9 passed
), plus
test_docker_builder.py
(
38 passed
). fixes FLYTE-SDK-4Z 🤖 Generated with Claude Code flyteorg/flyte-sdk