acoustic-carpenter-78188
07/07/2026, 4:06 PMcopy_files_to_context (src/flyte/_internal/imagebuild/utils.py) walks a user's source tree and copies each file into the remote image build context with shutil.copy2. copy2 copies file metadata as well as data (mode, timestamps, flags, xattrs via copystat), and on macOS that raises:
PermissionError: [Errno 1] Operation not permitted: '.../build.uc-image-builder/_flyte_abs_context/.../.git/config'
for flag- or SIP-protected files that get pulled into the context (e.g. entries under a user's .git directory). The raw traceback aborted the entire image build and surfaced in Sentry as an unhandled SDK crash (FLYTE-SDK-6F). The loop already tolerates FileNotFoundError (files that vanish mid-walk) but not PermissionError.
Fix
On PermissionError, fall back to shutil.copyfile (copies data only, no metadata) — which succeeds when only the metadata copy was blocked. Only if the data itself cannot be read do we skip the entry with a warning and keep the build going, mirroring the existing FileNotFoundError handling.
Tests
• test_copy_files_to_context_falls_back_when_copy2_permission_denied — copy2 raises PermissionError, contents still land via copyfile fallback.
• test_copy_files_to_context_skips_when_data_unreadable — data itself unreadable, entry skipped with warning, build continues.
14/14 tests in tests/flyte/imagebuild/test_utils.py pass.
fixes FLYTE-SDK-6F
🤖 Generated with Claude Code
flyteorg/flyte-sdkacoustic-carpenter-78188
07/10/2026, 1:12 PM