Skip to content

AioS3FileSystem._rm() ignores maxdepth and deletes every level #962

Description

@laughingman7743

Problem

AioS3FileSystem._rm() ignores maxdepth.
It expands each path with self._sync_fs.expand_path(p, recursive=recursive) (pyathena/filesystem/s3_async.py:191 on master e0e85da) and never passes maxdepth, which stays unused in **kwargs.
_rm(path, recursive=True, maxdepth=1) (and the generated sync AioS3FileSystem.rm() wrapper) therefore deletes every object under the path instead of only the first level.

S3FileSystem.rm() passes maxdepth to expand_path(); the async implementation does not.

Found by code reading during the review of #956 (#933).

Reproduction

fs = AioS3FileSystem(...)
await fs._pipe_file("s3://BUCKET/tmp/d/a", b"")
await fs._pipe_file("s3://BUCKET/tmp/d/sub/b", b"")
await fs._rm("s3://BUCKET/tmp/d", recursive=True, maxdepth=1)
# expected: tmp/d/sub/b remains
# actual: tmp/d/sub/b is deleted

Environment

  • PyAthena master e0e85da, fsspec 2026.9.0.

Proposed fix (optional)

Accept maxdepth in _rm() and pass it to expand_path(), as S3FileSystem.rm() does, with a test that deletes with maxdepth and checks that deeper objects remain.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions