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

Handle empty s3 response #142

Merged
merged 1 commit into from
Apr 5, 2024
Merged

Conversation

jrjohnson
Copy link
Contributor

What Changed & Why

After the update to AWS SDK v3 when searching for a revision the Contents on the response is not present if the revision hasn't been created yet. This seemed like the smallest change to fix the problem, and optional chaining is supported in Node 14, but I had to bump up the ecmaVersion in the eslint config to allow it.

Without this our deployed after updating to v4.0.1 have the error
TypeError: Cannot read properties of undefined (reading 'find') at [email protected]/node_modules/ember-cli-deploy-s3-index/lib/s3.js:169:45

Debugging this method, my response from AWS looks like:

{
  '$metadata': {
    httpStatusCode: 200,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  },
  IsTruncated: false,
  Marker: '',
  MaxKeys: 1000,
}

I wasn't able to find anything in the AWS upgrade notes or in the API docs that explains this difference which is why I made the changes so small and didn't attempt to check if Contents exists or count the responses instead. I'm happy to do this another way if someone is more familiar with the S3 API calls here.

Related issues

#138

PR Checklist

  • Add tests

People

@lukemelia @saravanak

After the update to AWS SDK v3 when searching for a revision the
Contents on the response is not present if the revision hasn't been
created yet. This seemed like the smallest change to fix the problem,
and optional chaining is supported in Node 14, but I had to bump up the
ecmaVersion in the eslint config to allow it.
@lukemelia lukemelia merged commit afb57ce into ember-cli-deploy:master Apr 5, 2024
8 checks passed
@lukemelia
Copy link
Contributor

Thanks @jrjohnson

@lukemelia lukemelia added the bug label Apr 5, 2024
@lukemelia
Copy link
Contributor

Released as 4.0.2

@jrjohnson jrjohnson deleted the v3-fix branch April 5, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants