BetaHuhn/deploy-to-vercel-action

Error: Cannot read property 'login' of null

wottpal opened this issue ยท 16 comments

While deploying I get the following error, do you have any ideas?

Error: Cannot read property 'login' of null

Screen Shot 2022-06-21 at 01 26 07

The deploy script is basically copy'n'paste from the docs:

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Deploy to Vercel CI

on:
  workflow_dispatch:
  push:
    branches: [develop]

jobs:
  deploy:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, '[skip ci]')"
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Deploy
        uses: BetaHuhn/deploy-to-vercel-action@v1
        with:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
          VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
          VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
          VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
          PRODUCTION: false

May it be the case that the user whose token is used in the action also needs to have a fork of the repo?

It looks like in file github.js there's a client created with

	const client = github.getOctokit(GITHUB_TOKEN, { previews: [ 'flash', 'ant-man' ] })

which then operates under the user. Further down in the file, the property login is read from data obtained by calling client.repos.getCommit.

If anyone else is facing this issue, pinning the action to v1.9.0 is a temporary work around confirmed by @wottpal (yieldgate/yieldgate#14 (comment))

The issue might be caused by one of the last dependency updates which broke something internal, will take a closer look sometime this week.

I did the workaround and still getting the same error @BetaHuhn
Screen Shot 2022-07-09 at 2 51 14 PM

yep also getting this error

@BetaHuhn I'm not sure but would this be something to do with how you request the api features?

I'm having trouble finding documentation about this aspect on github.

  1. highlighted github.getOctokit and google searched it, resulting in this page one result: https://github.com/actions/toolkit/blob/main/packages/github/README.md
  2. following the link in there to https://octokit.github.io/rest.js/v18
  3. tried to follow the link in there about api previews: https://octokit.github.io/rest.js/v18#previews ๐Ÿ‘‰๐Ÿป https://docs.github.com/en/rest/overview/api-previews/
  4. land on a page that says nothing about api previews.
  5. ????
  6. confused.

Another thing is, does repos.getCommit actually return an author object containing a login property?

answer: looks like your pulling values from this shape:

{
  "commit": {
    "author": {
      "name": string
    }
  },
  "author": {
    "login": string
  }
}

but if you look at the JSONSchema of that data.author object, it says it can possibly be null.

image

I just encountered this issue with my team: some of my colleagues were able to deploy, others not. It drove me crazy! And I refused to believe that the author object could be null for no reason.

But I think I found it, and it is kind of dumb: I noticed that some of my colleagues used an email in their git configuration which was not added to their Github profile. And indeed, after rectification, everything went well!

Hope this can help!

โš ๏ธ This issue has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

@BetaHuhn should be reopened probably.

I can fully confirm the finding by @Elindorath. It must be some coincidence that it suddenly worked for me that day.

Can you add this requirement to the Readme, please, @BetaHuhn?

โš ๏ธ This issue has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

โ€ฆ

Fixed by adding an email and name to the .gitconfig file

Hello, just update from my side, from few days we have the same issue:

  • Error: Cannot read properties of null (reading 'login')

Currently we are using BetaHuhn/deploy-to-vercel-action@v1.7.2

We were trying to change version for:
BetaHuhn/deploy-to-vercel-action@v1.9.0
BetaHuhn/deploy-to-vercel-action@v1.9.12

but the issue was not resolved. What we tried as well is to set:
- name: git_config
env:
GIT_AUTHOR_NAME: hardcoded name
GIT_AUTHOR_EMAIL: hardcoded email
run: |
git config --global user.email "$GIT_AUTHOR_EMAIL"
git config --global user.email "$GIT_AUTHOR_EMAIL"

and it's not working as well. Is there any update about issue?

I got same issue

I used the proposal written by @Elindorath above

Run the following
git config --local user.name "Name on Github"
git config --local user.email "use_the_email_for_your_account@github.com"

Then made a small change to a random file and commited, pushed and then it worked!

Maybe this would solve your issues also? @krystiankedra and @jerrywu001

Ran into the same problem on one machine.

Turned out I had a typo in the git config user.email.

Ran git config --local user.email "use_the_email_for_your_account" as @Finnepinnen suggested which fixed the issue