shallwefootball / upload-s3-action

github action for upload to S3 ☁️
https://github.com/marketplace/actions/upload-s3
163 stars 150 forks source link

Cannot read property 'Key' of undefined #27

Open slorber opened 3 years ago

slorber commented 3 years ago

I have the following:


      - uses: shallwefootball/s3-upload-action@master
        with:
          aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
          aws_bucket: "thread2video"
          source_dir: 'video/src'
          destination_dir: 'videos/video${{ github.run_id }}${{ github.run_number }}'

And get the following error:

Run shallwefootball/s3-upload-action@master
  with:
    aws_key_id: ***
    aws_secret_access_key: ***

    aws_bucket: thread2video
    source_dir: video/src
    destination_dir: videos/video67933283030
Error: AccessDenied: Access Denied
/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:6786
            throw err;
            ^

Error [TypeError]: Cannot read property 'Key' of undefined
    at ManagedUpload.callback (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:2459:36)
    at Response.finishSinglePart (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:20929:28)
    at Request.<anonymous> (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:7124:18)
    at Request.callListeners (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:11458:20)
    at Request.emit (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:11430:10)
    at Request.emit (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:7443:14)
    at Request.transition (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:6777:10)
    at AcceptorStateMachine.runTo (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:14564:12)
    at /home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:14576:10
    at Request.<anonymous> (/home/runner/work/_actions/shallwefootball/s3-upload-action/master/dist/index.js:6793:9) {
  message: "Cannot read property 'Key' of undefined",
  code: 'TypeError',
  time: 2021-03-23T11:05:27.014Z
}

It is not 100% clear why, wonder if it's not related to this code?

image

I believe the data might not be available when there is an error, so it might be due to an ACL permission (cf https://github.com/shallwefootball/upload-s3-action/issues/21)

JavierMonton commented 3 years ago

I'm having the same issue right now. There is another open issue that says that region is needed to solve this, but I think there isn't an option to specify the region.

In my case, I'm using a self-hosted machine and seems that data is undefined.

AgentGoldPaw commented 3 years ago

@JavierMonton i just saw this. You're correct this module doesn't allow for region. I may have time create a PR this weekend.

JavierMonton commented 3 years ago

Hi @drpym, thanks for you comment!

I think the error could be related to permissions too, in my case I found out that I had permissions for aws cp but not for aws sync and a lot of GH Actions were failing for me. I've forked the repository and tried to add manually the region (just to test it) but it was still failing. Finally, I ended up doing it manually (installing AWS Cli and using aws cp) and it worked fine.

hananmalka commented 3 years ago

Hi, Any news about this issue? I'm having the same error and couldn't find for a solution

AgentGoldPaw commented 3 years ago

The PR is open, but you can use the Aws cli as it is preinstalled in actions. Make sure to pass AWS_REGION.

On Sun, Jun 6, 2021 at 2:48 PM, hananmalka @.***> wrote:

Hi, Any news about this issue? I'm having the same error and couldn't find for a solution

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ankur0101 commented 2 years ago

Hi @drpym, thanks for you comment!

I think the error could be related to permissions too, in my case I found out that I had permissions for aws cp but not for aws sync and a lot of GH Actions were failing for me. I've forked the repository and tried to add manually the region (just to test it) but it was still failing. Finally, I ended up doing it manually (installing AWS Cli and using aws cp) and it worked fine.

I had the same error. How I fixed? - Created a bucket specific policy and attached to a user and this error vanished but the new one came forward.

dldx commented 2 years ago

For anyone else that ends up here, I believe this library requires public read access to be set. https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteAccessPermissionsReqd.html

panbanda commented 1 year ago

Yeah definitely don't need the public access-- For my GH hosted runners I usually use

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v3
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-2

      - name: Deploy to S3
        run: aws s3 sync --delete ./dist s3://...

But when dealing with my self hosted runners I usually have to do something different if I don't have access to the AWS CLI on the container running it.