Skip to content

AWS S3 ls requires trailing slash to list subdirectory contents #9701

@Revivekirin

Description

@Revivekirin

Description

  • Environment: Ubuntu 24.04, AWS CLI

  • Issue: While listing S3 bucket contents, I found an inconsistency when navigating subdirectories.

  • Steps to reproduce:

    1. Run aws s3 ls root1 → files and folders under root1 are listed correctly.
    2. Run aws s3 ls root1/root2 → no files are shown.
    3. Run aws s3 ls root1/root2/root2
    4. Run aws s3 ls root1/root2 again → files are listed correctly.
  • Expected behavior:
    aws s3 ls root1/root2 should list the contents inside root2 without requiring a trailing slash.

  • Actual behavior:
    The contents are only shown if a trailing slash / is added.

  • Notes:
    Not sure if this is a bug or intended behavior, but it feels unintuitive and inconvenient when navigating S3 buckets.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

aws s3 ls root1/root2 should directly show the contents of root2 without requiring a trailing slash.

Current Behavior

aws s3 ls root1/root2 shows no files unless a trailing slash / is added.

Reproduction Steps

  1. Run aws s3 ls root1 → contents appear.
  2. Run aws s3 ls root1/root2 → no contents.
  3. Run aws s3 ls root1/root2/root2/ → no contents
  4. Run aws s3 ls root1/root2 → contents appear

Possible Solution

Make aws s3 ls <path> list contents regardless of trailing slash.

Additional Information/Context

No response

CLI version used

downloaded with command curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip

Environment details (OS name and version, etc.)

linux Ubuntu 24.04
Window latest updated version

Metadata

Metadata

Assignees

Labels

p3This is a minor priority issueresponse-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 7 days.s3service-apiThis issue is due to a problem in a service API, not the SDK implementation.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions