Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListObjectVersions and ListMultipartUploads paginators send 0 for max items when input is nil #2379

Closed
ewbankkit opened this issue Nov 20, 2023 · 3 comments · Fixed by #2380
Labels
bug This issue is a bug. p0 This issue is the highest priority

Comments

@ewbankkit
Copy link

ewbankkit commented Nov 20, 2023

Describe the bug

My specific problem is to do with the S3 API's ListObjectVersionsInput.MaxKeys field, but the underlying cause may affect other APIs.

The recent (https://github.com/aws/aws-sdk-go-v2/releases/tag/release-2023-11-17) change to default value serialization, #2162, has caused the S3 ListObjectVersions API to return no object versions when no value (now nil) is specified for ListObjectVersionsInput.MaxKeys.
Previously (https://github.com/aws/aws-sdk-go-v2/releases/tag/release-2023-11-16) up to 1000 object versions were returned when no value was specified, as documented in the API Reference:

Sets the maximum number of keys returned in the response. By default, the action returns up to 1,000 key names.

Sniffing the HTTP request I can now see an explicit max-keys=0 URL query parameter added.

Expected Behavior

If no value for ListObjectVersionsInput.MaxKeys is specified, up to 1000 object version should be returned.

Current Behavior

See above.

Reproduction Steps

input := &s3.ListObjectVersionsInput{
	Bucket:  aws.String("tf-acc-test-7828939106372858870"),
}

pages := s3.NewListObjectVersionsPaginator(conn, input)
for pages.HasMorePages() {
	page, err := pages.NextPage(ctx)

	if err != nil {
		return err
	}

	for _, objectVersion := range page.Versions {
	}
}

leads to

http.url="https://tf-acc-test-7828939106372858870.s3.us-west-2.amazonaws.com/?max-keys=0&versions="
http.response.body=
| <?xml version="1.0" encoding="UTF-8"?>
| <ListVersionsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>tf-acc-test-7828939106372858870</Name><KeyMarker></KeyMarker><VersionIdMarker></VersionIdMarker><MaxKeys>0</MaxKeys><IsTruncated>false</IsTruncated></ListVersionsResult>

Possible Solution

No response

Additional Information/Context

Workaround is to add an explicit default value:

input := &s3.ListObjectVersionsInput{
	Bucket:  aws.String("tf-acc-test-7828939106372858870"),
	MaxKeys: aws.Int32(1000),
}

AWS Go SDK V2 Module Versions Used

% grep s3 go.mod 
	github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.14.0
	github.com/aws/aws-sdk-go-v2/service/s3 v1.43.0
	github.com/aws/aws-sdk-go-v2/service/s3control v1.37.0
	github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.3 // indirect

Compiler and Version used

go version go1.20.10 darwin/amd64

Operating System and version

macOS Ventura 13.6

@ewbankkit ewbankkit added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2023
@lucix-aws lucix-aws added p0 This issue is the highest priority and removed needs-triage This issue or PR still needs to be triaged. labels Nov 20, 2023
@lucix-aws
Copy link
Contributor

The handwritten paginator for ListObjectVersions was updated incorrectly as part of this change. Will work on a fix immediately.

change to default value serialization

As an aside, the behavior of default value serialization in the SDK itself was not changed. The service model was updated in a way that causes us to instead generate the affected fields like this as *type instead of the value variant.

@lucix-aws
Copy link
Contributor

Linked PR will correct this behavior.

Note that explicit use of ListObjectVersions / ListMultipartUploads is unaffected.

@lucix-aws lucix-aws changed the title Change to serialization of S3 ListObjectVersions API's MaxKeys default value causes no object versions to be returned ListObjectVersions and ListMultipartUploads paginators send 0 for max items when input is nil Nov 20, 2023
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

dlresende pushed a commit to cloudfoundry/backup-and-restore-sdk-release that referenced this issue Nov 23, 2023
**Issue:**

We realised that whilst bumping `aws-sdk-go-v2/services/s3` to version
`1.44.0` we found a breaking change where a default value for `MaxKeys`
in the `ListObjectVersionsInput` struct was being set to `0`, resulting
in 0 versions being returned. It should have been `1 000`.

```
input := &s3.ListObjectVersionsInput{
	Bucket:  aws.String("tf-acc-test-7828939106372858870"),
	MaxKeys: aws.Int32(1000),
}
```

More details: aws/aws-sdk-go-v2#2379

**Workaround:**

We are explicitly setting the `MaxKeys` to `1_000` as it should be.

[#186503787]

Signed-off-by: Diego Lemos <dlemos@vmware.com>
dlresende pushed a commit to cloudfoundry/backup-and-restore-sdk-release that referenced this issue Nov 23, 2023
**Issue:**

We realised that whilst bumping `aws-sdk-go-v2/services/s3` to version
`1.44.0` we found a breaking change where a default value for `MaxKeys`
in the `ListObjectVersionsInput` struct was being set to `0`, resulting
in 0 versions being returned. It should have been `1 000`.

```
input := &s3.ListObjectVersionsInput{
	Bucket:  aws.String("tf-acc-test-7828939106372858870"),
	MaxKeys: aws.Int32(1000),
}
```

More details: aws/aws-sdk-go-v2#2379

**Workaround:**

We are explicitly setting the `MaxKeys` to `1_000` as it should be.

[#186503787]

Signed-off-by: Diego Lemos <dlemos@vmware.com>
dlresende pushed a commit to cloudfoundry/backup-and-restore-sdk-release that referenced this issue Nov 23, 2023
**Issue:**

We realised that whilst bumping `aws-sdk-go-v2/services/s3` to version
`1.44.0` we found a breaking change where a default value for `MaxKeys`
in the `ListObjectVersionsInput` struct was being set to `0`, resulting
in 0 versions being returned. It should have been `1 000`.

```
input := &s3.ListObjectVersionsInput{
	Bucket:  aws.String("tf-acc-test-7828939106372858870"),
	MaxKeys: aws.Int32(1000),
}
```

More details: aws/aws-sdk-go-v2#2379

**Workaround:**

We are explicitly setting the `MaxKeys` to `1_000` as it should be.

[#186503787]

Signed-off-by: Diego Lemos <dlemos@vmware.com>
dlresende pushed a commit to cloudfoundry/backup-and-restore-sdk-release that referenced this issue Nov 23, 2023
**Issue:**

We realised that whilst bumping `aws-sdk-go-v2/services/s3` to version
`1.44.0` we found a breaking change where a default value for `MaxKeys`
in the `ListObjectVersionsInput` struct was being set to `0`, resulting
in 0 versions being returned. It should have been `1 000`.

```
input := &s3.ListObjectVersionsInput{
	Bucket:  aws.String("tf-acc-test-7828939106372858870"),
	MaxKeys: aws.Int32(1000),
}
```

More details: aws/aws-sdk-go-v2#2379

**Workaround:**

We are explicitly setting the `MaxKeys` to `1_000` as it should be.

[#186503787]

Signed-off-by: Diego Lemos <dlemos@vmware.com>
Cryogenics-CI pushed a commit to cloudfoundry/backup-and-restore-sdk-release that referenced this issue Nov 23, 2023
* Bump github.com/aws/aws-sdk-go-v2 in /src/s3-blobstore-backup-restore

Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.22.2 to 1.23.0.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@v1.22.2...v1.23.0)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump github.com/aws/aws-sdk-go-v2/credentials

Bumps [github.com/aws/aws-sdk-go-v2/credentials](https://github.com/aws/aws-sdk-go-v2) from 1.15.2 to 1.16.1.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/v1.16.1/CHANGELOG.md)
- [Commits](aws/aws-sdk-go-v2@config/v1.15.2...v1.16.1)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/credentials
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump github.com/aws/aws-sdk-go-v2/service/sts

Bumps [github.com/aws/aws-sdk-go-v2/service/sts](https://github.com/aws/aws-sdk-go-v2) from 1.25.1 to 1.25.4.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@config/v1.25.1...config/v1.25.4)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/service/sts
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump github.com/aws/aws-sdk-go-v2/service/s3

Bumps [github.com/aws/aws-sdk-go-v2/service/s3](https://github.com/aws/aws-sdk-go-v2) from 1.42.1 to 1.43.1.
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Commits](aws/aws-sdk-go-v2@service/s3/v1.42.1...service/s3/v1.43.1)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/service/s3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix compilation issues

* Fix version pagination by adding default batch size

**Issue:**

We realised that whilst bumping `aws-sdk-go-v2/services/s3` to version
`1.44.0` we found a breaking change where a default value for `MaxKeys`
in the `ListObjectVersionsInput` struct was being set to `0`, resulting
in 0 versions being returned. It should have been `1 000`.

```
input := &s3.ListObjectVersionsInput{
	Bucket:  aws.String("tf-acc-test-7828939106372858870"),
	MaxKeys: aws.Int32(1000),
}
```

More details: aws/aws-sdk-go-v2#2379

**Workaround:**

We are explicitly setting the `MaxKeys` to `1_000` as it should be.

[#186503787]

Signed-off-by: Diego Lemos <dlemos@vmware.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Diego Lemos <dlemos@vmware.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Konstantin Semenov <ksemenov@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p0 This issue is the highest priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants