Thanks to visit codestin.com
Credit goes to github.com

Skip to content

mock-aws-s3-v3: ListObjectsV2Command pagination tokens are undefined #454

Description

@ZackPedretti

Description

When using mock-aws-s3-v3 to test code that relies on S3 pagination, the mock does not return ContinuationToken or NextContinuationToken for ListObjectsV2Command responses. As a result, any logic that depends on paginated listings cannot be tested using this library.

According to AWS S3 behavior, when the number of returned objects exceeds MaxKeys, the response should include:

  • IsTruncated: true
  • NextContinuationToken: "[token]"
  • and should accept ContinuationToken in the next request

The mock currently returns the full object list with no pagination, and both tokens remain undefined.

Steps to reproduce

import { S3Client, ListObjectsV2Command } from "@aws-sdk/client-s3";
import { mockClient } from "mock-aws-s3-v3";

const mock = mockClient(S3Client);

mock.on(ListObjectsV2Command).resolves({
  Contents: [...Array(200).keys()].map(i => ({ Key: `file-${i}` })),
  // Expecting pagination when > MaxKeys (default 1000 or custom)
});

const client = new S3Client({});

const res = await client.send(
  new ListObjectsV2Command({
    Bucket: "test-bucket",
    MaxKeys: 10,
  })
);

console.log(res.IsTruncated);           // expected: true  
console.log(res.NextContinuationToken); // expected: string
console.log(res.Contents.length);       // expected: 10

Actual behavior

  • Returning up to MaxKeys number of objects
  • But NextContinuationToken is undefined

Expected behavior

  • Should return up to MaxKeys number of objects
  • Should return a NextContinuationToken
  • Should take an optional ContinuationToken

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions