Skip to content

Commit dde4bca

Browse files
committed
fix: raise CodeBundleError for include paths outside the bundle root
An Environment.include path that resolves outside the bundle root (or matches no file) raised a bare ValueError that leaked as a crash report (FLYTE-SDK-5M), even though the message is already user-actionable ("Pass --root-dir ..."). Convert these to CodeBundleError (a RuntimeUserError), which keeps the same helpful message but is filtered from Sentry as a user configuration error. fixes FLYTE-SDK-5M Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
1 parent fc78c93 commit dde4bca

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/flyte/_code_bundle/_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def ls_files(
141141
else:
142142
matched = glob.glob(str(p))
143143
if not matched:
144-
raise ValueError(f"include path {entry!r} is not a file, directory, or matching glob pattern.")
144+
from flyte.errors import CodeBundleError
145+
146+
raise CodeBundleError(f"include path {entry!r} is not a file, directory, or matching glob pattern.")
145147
extra_paths.extend(m for m in matched if pathlib.Path(m).is_file())
146148

147149
existing = set(all_files)
@@ -153,7 +155,13 @@ def ls_files(
153155
try:
154156
rel = resolved.relative_to(resolved_source)
155157
except ValueError as exc:
156-
raise ValueError(
158+
from flyte.errors import CodeBundleError
159+
160+
# An include path that resolves outside the bundle root is a user
161+
# configuration problem (the message tells them how to fix it), not an SDK
162+
# bug. Raise a typed user error so it is filtered from crash reporting instead
163+
# of leaking as a raw ValueError (FLYTE-SDK-5M).
164+
raise CodeBundleError(
157165
f"include path {extra!r} is outside the bundle root {source_path!s}. "
158166
f"Pass --root-dir (or configure it) one level up so every include lives under the root."
159167
) from exc

tests/flyte/code_bundle/test_includes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from flyte._code_bundle._includes import collect_env_include_files
2626
from flyte._code_bundle._utils import ls_files
2727
from flyte._code_bundle.bundle import build_code_bundle
28+
from flyte.errors import CodeBundleError
2829

2930

3031
def _make_env_at(tmp_dir: Path, name: str, include: tuple[str, ...]) -> flyte.TaskEnvironment:
@@ -96,7 +97,7 @@ def test_ls_files_rejects_path_outside_source():
9697
outside_file.write_text("nope")
9798

9899
with tempfile.TemporaryDirectory() as inside:
99-
with pytest.raises(ValueError, match="outside the bundle root"):
100+
with pytest.raises(CodeBundleError, match="outside the bundle root"):
100101
ls_files(
101102
Path(inside),
102103
copy_file_detection="all",

0 commit comments

Comments
 (0)