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

fix: add string fallback for S3#Expires field when not a date-time #4577

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Jan 23, 2024

See aws/aws-sdk-js-v3#5715.

Adds an S3-only model transform that adds an additional field ExpiresString: string where any operation output has Expires: Date as an output member. This field will contain the raw value from Expires response header in all cases.

If Expires response header is not a date format, this will no longer throw an exception. Users can access the ExpiresString field as a fallback, and Expires will be set to undefined in that case.

Checklist
  • npm run test passes
  • .d.ts file is updated
  • changelog is added, npm run add-change

@kuhe kuhe requested a review from a team as a code owner January 23, 2024 19:38
@kuhe
Copy link
Contributor Author

kuhe commented Jan 23, 2024

testing:

// in v2/workspace/s3 folder
import S3 from "../../clients/s3";

var s3 = new S3({
  region: 'us-west-2'
});

(async () => {
  // both Expires and ExpiresString will be set on the returned object.
  const get = await s3.getObject({
    Bucket: "...",
    Key: "goodexpires",
  }).promise();

  console.log("expires and expiresString", get.Expires, get.ExpiresString);

  // this emits a warning, but does not throw. Expires becomes undefined and only ExpiresString is set.
  const get2 = await s3.headObject({
    Bucket: "...",
    Key: "badexpires",
  }).promise();

  console.log("expires and expiresString", get2.Expires, get2.ExpiresString);
})();

@kuhe kuhe merged commit c1ddb71 into aws:master Jan 24, 2024
1 check passed
@kuhe kuhe deleted the s3/expires branch January 24, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants