Skip to content

fix: raise CodeBundleError for bad Environment.include paths - #1232

Open
EngHabu wants to merge 3 commits into
mainfrom
fix/sentry-5m-bundle-root
Open

fix: raise CodeBundleError for bad Environment.include paths#1232
EngHabu wants to merge 3 commits into
mainfrom
fix/sentry-5m-bundle-root

Conversation

@EngHabu

@EngHabu EngHabu commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Problem

An Environment.include path that resolves outside the bundle root, or that matches no file / directory / glob, raised a bare ValueError from flyte._code_bundle._utils that leaked as a crash report:

  • FLYTE-SDK-5M — "include path '…/_path_setup.py' is outside the bundle root … Pass --root-dir …"
  • FLYTE-SDK-5Y — "include path '…' is not a file, directory, or matching glob pattern."

Both messages are already user-actionable; neither should have been an unhandled SDK crash.

Fix

Convert all three include-path validation ValueErrors in _utils.py to CodeBundleError — a RuntimeUserError that keeps the same helpful message and is filtered from crash reporting via the _is_user_error allowlist:

  1. ls_files — include path resolves outside the bundle root (FLYTE-SDK-5M).
  2. ls_files — include path matches no file, directory or glob (FLYTE-SDK-5Y).
  3. ls_relative_files — same no-match case on the copy_style="none" route (build_code_bundlebuild_code_bundle_from_relative_pathslist_relative_files_to_bundle). This is the same user error reached through a different code path; it had no Sentry issue of its own yet only because copy_style="none" is rarer. Its message is also reworded from "File … is not a valid file, directory, or glob pattern" to "include path …", naming the thing the user actually typed and matching its sibling in ls_files.

Tests

  • test_ls_files_rejects_path_outside_source, test_build_code_bundle_include_outside_source_raises and test_ls_relative_files_invalid_path now expect CodeBundleError.
  • New test_build_code_bundle_copy_style_none_missing_include_raises covers the third site end-to-end through the public build_code_bundle API. Verified failing on unpatched src/, passing with the fix.

fixes FLYTE-SDK-5M
fixes FLYTE-SDK-5Y

@EngHabu EngHabu added the sentry-fix Fix for an issue surfaced by Sentry label Jun 19, 2026
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch 5 times, most recently from 612973b to c924bf1 Compare June 26, 2026 16:11
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch 5 times, most recently from d429394 to 9119a89 Compare July 3, 2026 02:52
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch 5 times, most recently from aa22f9a to 7c79cc8 Compare July 10, 2026 16:25
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch 2 times, most recently from ddef1f9 to 654f238 Compare July 14, 2026 17:35
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch 6 times, most recently from 8d2b7e9 to 1e7422d Compare July 27, 2026 02:06
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch 3 times, most recently from e137128 to c5ee577 Compare July 29, 2026 21:24
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch from c5ee577 to 4a78071 Compare August 21, 2026 16:12
@EngHabu EngHabu changed the title fix: raise CodeBundleError for include paths outside the bundle root fix: raise CodeBundleError for bad Environment.include paths Aug 21, 2026
… bundle root

An Environment.include path that resolves outside the bundle root (or matches
no file/dir/glob) raised a bare ValueError that leaked as a crash report
(FLYTE-SDK-5M outside-root, FLYTE-SDK-5Y no-match-glob), even though the
message is already user-actionable ("Pass --root-dir ..." / "is not a file,
directory, or matching glob pattern"). 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
fixes FLYTE-SDK-5Y

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
…one" path

`ls_relative_files` is the third site in `_code_bundle/_utils.py` that rejects an
`Environment.include` entry, and the only one still raising a bare `ValueError`.
It is reached from `build_code_bundle(copy_style="none", additional_files=...)`
via `build_code_bundle_from_relative_paths` -> `list_relative_files_to_bundle`,
so the path it complains about came straight from the user's `include=`.

Same reasoning as the two sites already converted in this PR: an include that
matches no file, directory or glob is the user's configuration, not an SDK bug,
so it should be a typed user error that crash reporting filters out instead of a
raw `ValueError` reported as a crash. The message is also reworded from
"File ... is not a valid file, directory, or glob pattern" to name the concept
the user actually typed ("include path ..."), matching its sibling in `ls_files`.

fixes FLYTE-SDK-5M

Signed-off-by: Haytham Abuelfutuh <haytham@afutuh.com>
@EngHabu
EngHabu force-pushed the fix/sentry-5m-bundle-root branch from 4a78071 to 87e82bd Compare September 3, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sentry-fix Fix for an issue surfaced by Sentry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant