upload-s3-action icon indicating copy to clipboard operation
upload-s3-action copied to clipboard

Cannot read property 'Key' of undefined

Open slorber opened this issue 3 years ago • 8 comments

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)

slorber avatar Mar 23 '21 11:03 slorber

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.

JavierMonton avatar Mar 23 '21 15:03 JavierMonton

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

AgentGoldPaw avatar Apr 15 '21 21:04 AgentGoldPaw

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.

JavierMonton avatar Apr 16 '21 07:04 JavierMonton

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

hananmalka avatar Jun 06 '21 21:06 hananmalka

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.

AgentGoldPaw avatar Jun 06 '21 22:06 AgentGoldPaw

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.

ankur0101 avatar Jun 22 '22 10:06 ankur0101

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

dldx avatar Jul 19 '22 16:07 dldx

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.

panbanda avatar Sep 04 '23 04:09 panbanda