Skip to content

BucketPath uses backslash separators on Windows #322

Closed

Description

@ahsimb

Summary

On Windows, BucketPath sends paths with backslash separators to BucketFS, so any operation on a nested path is wrong.

BucketPath.__init__ stores the path as PurePath(path). On Windows that gives a PureWindowsPath. Only _get_relative_posix(), used by _navigate(), converts \ to /. Everything else uses str(self._path) directly:

  • read() → self._bucket_api.download(str(self._path), ...)
  • write() → self._bucket_api.upload(str(self._path), ...)
  • rm() → self._bucket_api.delete(str(self._path))
  • __str__ / as_udf_path() / iterdir() children also produce backslash paths

Reproduction

This emulates Windows on Linux by patching PurePath in exasol/bucketfs/_path.py to PureWindowsPath. Tested with exasol-bucketfs 2.3.0.

import pathlib, exasol.bucketfs._path as m
m.PurePath = pathlib.PureWindowsPath  # emulate Windows

class Api:
    udf_path = "/buckets/bfsdefault/default"
    files = ["dir/sub/a.txt"]
    def upload(self, p, d): print("upload:", repr(p))
    def download(self, p, c): print("download:", repr(p)); return []
    def delete(self, p): print("delete:", repr(p))

root = m.BucketPath("", Api())
p = root.joinpath("dir/sub/a.txt")
p.write(b"x"); list(p.read()); p.rm()
print([str(x) for x in root.joinpath("dir").iterdir()])
print(p.as_udf_path())

Output:

upload:   'dir\\sub\\a.txt'
download: 'dir\\sub\\a.txt'
delete:   'dir\\sub\\a.txt'
['dir\\sub']
\buckets\bfsdefault\default\dir\sub\a.txt

_build_url puts the path into the URL as-is, so requests encodes it as .../default/dir%5Csub%5Ca.txt. Uploads then create a file whose name literally contains backslashes, and downloads and deletes of existing nested files fail. The UDF path returned by as_udf_path() is not valid inside the database either.

Expected

BucketFS paths are always POSIX paths, whatever the client OS.

Suggested fix

Store the path as PurePosixPath instead of PurePath in BucketPath, and in as_udf_path(). _get_relative_posix() can then drop its special case for PureWindowsPath. A unit test that runs the operations above with Windows-style paths, or a Windows CI job, would prevent regressions.

Context

Found while checking whether the Exasol MCP Server can run on Windows. Its BucketFS tools depend on BucketPath.

Activity

  1. added
    bugUnwanted / harmful behavior
    on Oct 2, 2026
  2. added a commit that references this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugUnwanted / harmful behavior

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions