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
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.
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.
- highlighted
github.getOctokit
and google searched it, resulting in this page one result: https://github.com/actions/toolkit/blob/main/packages/github/README.md - following the link in there to https://octokit.github.io/rest.js/v18
- 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/
- land on a page that says nothing about api previews.
- ????
- confused.
Another thing is, does repos.getCommit
actually return an author object containing a login
property?
- https://octokit.github.io/rest.js/v18#repos-get-commit (where's the response object documentation lol? )
- https://docs.github.com/en/rest/commits/commits#get-a-commit
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.
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!
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?
โฆ
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