Skip to content
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
ricardo-devis-agullo merged 5 commits into
masterfrom
feat/paginate-s3-gs-list-remove
Jun 21, 2026
Merged

feat(storage): paginate listSubDirectories and removeDir for S3 and GS#342
ricardo-devis-agullo merged 5 commits into
masterfrom
feat/paginate-s3-gs-list-remove

Conversation

@ricardo-devis-agullo

@ricardo-devis-agullo ricardo-devis-agullo commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Updates the S3 and Google Cloud Storage adapters to correctly handle paginated responses in listSubDirectories and removeDir.

Changes

  • Google Cloud Storage (packages/oc-gs-storage-adapter): follows the pageToken returned in nextQuery across pages when listing subdirectories and deleting files.
  • S3 (packages/oc-s3-storage-adapter): follows NextMarker for delimited lists and falls back to the last Key for non-delimited lists when responses are truncated.
  • Updated mocks to simulate paginated bucket responses.
  • Added unit tests for paginated listSubDirectories and removeDir on both adapters.

Test plan

  • npm test passes (109 tests, including the new pagination tests for S3 and GS).

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 listSubDirectories via NextMarker for delimited listings and paginate removeDir via markers (falling back to last Key).
  • Google Cloud Storage: disable autoPaginate and follow nextQuery.pageToken across pages for both listSubDirectories and removeDir.
  • 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 thread packages/oc-s3-storage-adapter/src/index.ts Outdated
Comment on lines +125 to +129
do {
const options: {
prefix: string;
autoPaginate: false;
pageToken?: string;
Comment thread packages/oc-gs-storage-adapter/src/index.ts
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>
@ricardo-devis-agullo
ricardo-devis-agullo merged commit 8e44916 into master Jun 21, 2026
@ricardo-devis-agullo
ricardo-devis-agullo deleted the feat/paginate-s3-gs-list-remove branch June 21, 2026 20:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants