This repository was archived by the owner on Jul 5, 2026. It is now read-only.
feat(storage): paginate listSubDirectories and removeDir for S3 and GS#342
Merged
Merged
Conversation
Implements continuation/pageToken handling so listing and removing directories works correctly when buckets return paginated results. Adds mock-based tests for paginated list and remove behavior.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the S3 and Google Cloud Storage adapters to correctly handle paginated results when listing subdirectories and deleting directory contents, ensuring multi-page buckets are fully traversed.
Changes:
- S3: paginate
listSubDirectoriesviaNextMarkerfor delimited listings and paginateremoveDirvia markers (falling back to lastKey). - Google Cloud Storage: disable
autoPaginateand follownextQuery.pageTokenacross pages for bothlistSubDirectoriesandremoveDir. - Extend mocks and add unit tests to cover paginated bucket behavior for both adapters.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/oc-s3-storage-adapter/src/index.ts | Adds pagination to listSubDirectories and removeDir using S3 ListObjects markers. |
| packages/oc-s3-storage-adapter/test/s3.test.ts | Adds tests verifying pagination behavior for S3 listing and deletion. |
| packages/oc-s3-storage-adapter/mocks/@aws-sdk/client-s3.js | Extends mock to simulate paginated S3 listObjects responses. |
| packages/oc-gs-storage-adapter/src/index.ts | Adds manual pageToken-based pagination to GCS listing and deletion. |
| packages/oc-gs-storage-adapter/test/gs.test.ts | Adds tests verifying pageToken pagination for GCS listing and deletion. |
| packages/oc-gs-storage-adapter/mocks/@google-cloud/storage.js | Extends mock to simulate paginated getFiles responses with pageToken. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+205
to
+208
| // S3 returns NextMarker when a Delimiter is set and the list is truncated. | ||
| // Guard against an infinite loop if S3 ever omits it while truncated. | ||
| marker = data.IsTruncated && data.NextMarker ? data.NextMarker : undefined; | ||
| } while (marker); |
Comment on lines
+125
to
+129
| do { | ||
| const options: { | ||
| prefix: string; | ||
| autoPaginate: false; | ||
| pageToken?: string; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the S3 and Google Cloud Storage adapters to correctly handle paginated responses in listSubDirectories and removeDir.
Changes
Test plan