Skip to content

fix: avoid trailing filesystem directory probes#4122

Open
fengjikui wants to merge 1 commit into
dlt-hub:develfrom
fengjikui:codex/filesystem-no-trailing-dirs
Open

fix: avoid trailing filesystem directory probes#4122
fengjikui wants to merge 1 commit into
dlt-hub:develfrom
fengjikui:codex/filesystem-no-trailing-dirs

Conversation

@fengjikui

Copy link
Copy Markdown

Description

Fixes #3866.

FilesystemClient.dataset_path and FilesystemClient.get_table_dir() are passed directly to fsspec directory probes such as isdir() and exists(). They currently force a trailing separator, which is benign on some backends but can fail on stricter implementations such as OneLake/Fabric.

This keeps the existing table-prefix behavior for layouts that need folder-style prefixes, but returns dataset/table directory paths without a trailing separator before those paths are probed or converted to remote URLs.

Validation

env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy uv run --with pyparsing pytest \
  'tests/load/filesystem/test_filesystem_client.py::test_filesystem_dirs_do_not_have_trailing_separators[data-{table_name}/{load_id}.{file_id}.{ext}]' \
  'tests/load/filesystem/test_filesystem_client.py::test_filesystem_dirs_do_not_have_trailing_separators[data-{table_name}.{load_id}.{file_id}.{ext}]' -q
# 2 passed

env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy uv run --with pyparsing pytest \
  tests/load/filesystem/test_filesystem_client.py::test_list_dlt_table_files_with_separator_in_pipeline_name -q
# 5 passed

env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy uv run --with pyparsing pytest \
  'tests/load/filesystem/test_filesystem_client.py::test_successful_load[data-{table_name}/{load_id}.{file_id}.{ext}-replace]' \
  'tests/load/filesystem/test_filesystem_client.py::test_successful_load[memory:///m-{table_name}/{load_id}.{file_id}.{ext}-replace]' -q
# 2 passed

env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy uv run ruff check \
  dlt/destinations/impl/filesystem/filesystem.py \
  tests/load/filesystem/test_filesystem_client.py
# All checks passed!

env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy uv run python -m py_compile \
  dlt/destinations/impl/filesystem/filesystem.py \
  tests/load/filesystem/test_filesystem_client.py
# passed

git diff --check
# passed

I also tried the full parametrized test_filesystem_dirs_do_not_have_trailing_separators locally. The local data cases passed; remote bucket cases require credentials or optional filesystem extras that are not present in my local environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FilesystemClient trailing slash causes OneLake 403 at initialize_storage and truncate_tables

1 participant