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

Cannot read property 'Key' of undefined #27

Open
slorber opened this issue Mar 23, 2021 · 8 comments
Open

Cannot read property 'Key' of undefined #27

slorber opened this issue Mar 23, 2021 · 8 comments

Comments

@slorber
Copy link

slorber commented Mar 23, 2021

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 #21)

@JavierMonton
Copy link

JavierMonton commented Mar 23, 2021

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
Copy link

@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
Copy link

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
Copy link

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

@AgentGoldPaw
Copy link

AgentGoldPaw commented Jun 6, 2021 via email

@ankur0101
Copy link

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
Copy link

dldx commented Jul 19, 2022

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
Copy link

panbanda commented Sep 4, 2023

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.

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

No branches or pull requests

7 participants