ms-teams-notification icon indicating copy to clipboard operation
ms-teams-notification copied to clipboard

TypeError: Cannot read property 'avatar_url' or null

Open mpconte opened this issue 3 years ago • 38 comments

Hello,

I can't reproduce this all the time, but maybe every other time I get the following error:

TypeError: Cannot read property 'avatar_url' of null at Object.createMessageCard (C:\Users\rdbot\Desktop\action-runners\pdp_utils\_work\_actions\jdcargile\ms-teams-notification\v1.2\dist\index.js:2341:39) at C:\Users\rdbot\Desktop\action-runners\pdp_utils\_work\_actions\jdcargile\ms-teams-notification\v1.2\dist\index.js:2959:54 at Generator.next (<anonymous>) at fulfilled (C:\Users\rdbot\Desktop\action-runners\pdp_utils\_work\_actions\jdcargile\ms-teams-notification\v1.2\dist\index.js:2906:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) ##[error]Cannot read property 'avatar_url' of null

mpconte avatar Sep 08 '20 16:09 mpconte

@mpconte, do you have a user that is making commits that doesn't have an avatar? I can test this myself, but curious whether you're seeing any consistency from the users who commit who are seeing this issue?

jdcargile avatar Sep 08 '20 16:09 jdcargile

Yes, I'm performing the commit and I don't have an avatar in Microsoft Teams and I think someone else makes commits too but does have one. Does an avatar have to be necessary?

mpconte avatar Sep 08 '20 16:09 mpconte

Thanks! I will take a look at this before the end of the week.

jdcargile avatar Sep 09 '20 02:09 jdcargile

@mpconte, this is referencing the author of the commit in GitHub. I can see that you have an avatar in GitHub. Do you have an automated task that is creating the commits for you when it fails?

jdcargile avatar Sep 09 '20 05:09 jdcargile

@jdcargile My gihub workflow using this action doesn't run on commits (sorry), I have it set as a workflow_dispatch to checkout changes, build and package it and notify microsoft teams at the end if the previous steps succeed.

mpconte avatar Sep 09 '20 12:09 mpconte

It looks like the issue is reproduced, when the last commit is made by the user, whose email is not registered in GitHub

vtrusevich-incomm avatar Oct 07 '20 17:10 vtrusevich-incomm

@jdcargile , I see, that the author is taken from commit here https://github.com/jdcargile/ms-teams-notification/blob/a94290dd26cfcbe65dee7b4fbb171401d060ceef/dist/index.js#L2958. Looks like it is needed to add some checks on author existence before building the card

vtrusevich-incomm avatar Oct 07 '20 17:10 vtrusevich-incomm

Hey, I am running into the same issue....any good news?

dnepusb2 avatar Dec 16 '20 17:12 dnepusb2

I'm also running into this issue, is there any progress on a fix? Error is here: TypeError: Cannot read property 'avatar_url' of null at Object.createMessageCard (/home/runner/work/_actions/jdcargile/ms-teams-notification/v1.2/dist/index.js:2341:39) at /home/runner/work/_actions/jdcargile/ms-teams-notification/v1.2/dist/index.js:2959:54 at Generator.next () at fulfilled (/home/runner/work/_actions/jdcargile/ms-teams-notification/v1.2/dist/index.js:2906:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) Error: Cannot read property 'avatar_url' of null

tsposato avatar Dec 17 '20 00:12 tsposato

Thank you all for your comments and questions. What would you suggest we use for the author if it is not found? Should I do a default avatar image or omit the image altogether?

jdcargile avatar Dec 17 '20 15:12 jdcargile

He JD, Thanks for the quick follow up. From my perspective:

  • Author undefined
  • Default avatar image

Cheers and thanks again!

dnepusb2 avatar Dec 17 '20 15:12 dnepusb2

Sounds good to me.

tsposato avatar Dec 17 '20 18:12 tsposato

This is fixed in #7. To pick up the new version, update your action version to use v1.3. See snippet below for more information.

uses: jdcargile/[email protected]

jdcargile avatar Dec 18 '20 03:12 jdcargile

I updated to 1.3 but I still received the same error.

tsposato avatar Dec 18 '20 06:12 tsposato

I updated to 1.3 but I still received the same error.

@tsposato, can you try using uses: jdcargile/ms-teams-notification (don't provide the version so it grabs master)? If that works I will create another release. I just pushed what I think will fix this finally.

jdcargile avatar Dec 18 '20 06:12 jdcargile

@tsposato, can you try using uses: jdcargile/ms-teams-notification (don't provide the version so it grabs master)? If that works I will create another release. I just pushed what I think will fix this finally.

Will do. Not sure I'll get to test this until Monday as 5pm has rolled around but I'll let you know the outcome as soon as I can.

tsposato avatar Dec 18 '20 06:12 tsposato

The other weird thing is that the person in question does actually have an avatar set. Unless I'm misunderstanding the way it retrieves an avatar. Is there something strange about how GitHub does things avatar wise I'm not getting?

tsposato avatar Dec 18 '20 06:12 tsposato

This might not be fixed then. Perhaps I need to query the user directly before trying to grab their information. I can look into this more tomorrow.

jdcargile avatar Dec 18 '20 07:12 jdcargile

Slightly different error when using master now @jdcargile :

TypeError: Cannot read property 'login' of null at Object.createMessageCard (/home/runner/work/_actions/jdcargile/ms-teams-notification/master/dist/index.js:2461:85) at /home/runner/work/_actions/jdcargile/ms-teams-notification/master/dist/index.js:3090:54 at Generator.next () at fulfilled (/home/runner/work/_actions/jdcargile/ms-teams-notification/master/dist/index.js:3044:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) Error: Cannot read property 'login' of null

tsposato avatar Dec 21 '20 01:12 tsposato

Ok, so after some more digging it turns out the user had incorrectly spelt their email in their git user.email settings on one of their clients, hence why the user isn't being linked to their github account correctly. I think it should still probably be 'caught' instead of just failing completely though. Maybe just grab the name from the commit message and use that default avatar.

tsposato avatar Dec 21 '20 04:12 tsposato

Hi @jdcargile,

Getting the below error when using "uses: jdcargile/ms-teams-notification" instead of uses: jdcargile/[email protected]. Kindly suggest. The workflow is not valid. .github/workflows/terraform-validate.yml (Line: 182, Col: 17): Expected format {org}/{repo}[/path]@ref. Actual 'jdcargile/ms-teams-notification' Input string was not in a correct format.

akshata-kenchanagudd avatar Jan 21 '21 13:01 akshata-kenchanagudd

@jdcargile can you release a v1.4 that includes this commit - https://github.com/jdcargile/ms-teams-notification/commit/3e536e08814945d8518044475b58e52e01881d02?

stuartforrest-infinity avatar Jul 07 '21 12:07 stuartforrest-infinity

@jdcargile facing same issue - using v1.3

TypeError: Cannot read property 'avatar_url' of null at Object.createMessageCard (/home/runner/work/_actions/jdcargile/ms-teams-notification/v1.3/dist/index.js:2446:16) at /home/runner/work/_actions/jdcargile/ms-teams-notification/v1.3/dist/index.js:3088:54 at Generator.next () at fulfilled (/home/runner/work/_actions/jdcargile/ms-teams-notification/v1.3/dist/index.js:3042:58) at processTicksAndRejections (internal/process/task_queues.js:93:5) Error: Cannot read property 'avatar_url' of null

gspindev avatar Jul 08 '21 09:07 gspindev

The other weird thing is that the person in question does actually have an avatar set. Unless I'm misunderstanding the way it retrieves an avatar. Is there something strange about how GitHub does things avatar wise I'm not getting?

We experienced this exact problem. When I dug in further, it appears that the author, was different than who committed... that author wasn't registered in GitHub from Name and email, but SSH keys are.. so he is a valid contributor on the repository, but GitHub doesn't recognize the email he committed with (because he didn't add that in his profile), yet his SSH key's re valid to commit.

I propose that if avatar_url fails, you put in a default avatar image, instead of failing the job.

image

rwetzeler avatar Jul 30 '21 14:07 rwetzeler

The other weird thing is that the person in question does actually have an avatar set. Unless I'm misunderstanding the way it retrieves an avatar. Is there something strange about how GitHub does things avatar wise I'm not getting?

We experienced this exact problem. When I dug in further, it appears that the author, was different than who committed... that author wasn't registered in GitHub from Name and email, but SSH keys are.. so he is a valid contributor on the repository, but GitHub doesn't recognize the email he committed with (because he didn't add that in his profile), yet his SSH key's re valid to commit.

I propose that if avatar_url fails, you put in a default avatar image, instead of failing the job.

image

Hi mate, have you got a pull request that shows how to fix this? Most of our users do not have avatars.

825i avatar Sep 01 '21 08:09 825i

Is there a fix for this issue yet ?

mariam-alexander avatar Nov 17 '21 10:11 mariam-alexander

same here, started having this issue since yesterday! all was good until suddenly it stopped! the weird thing is that this happens only to 1 of my projects. in the other projects it works fine!

lumos94 avatar Dec 07 '21 15:12 lumos94

Having this issue since last week. Looks like 3e536e0 fixes it @jdcargile ?

dennistex avatar Jan 12 '22 20:01 dennistex

anibody fixed this issue already?

EvgeniyRub avatar Feb 16 '22 09:02 EvgeniyRub

Any news on this bug ?

bfernandes-d avatar May 27 '22 10:05 bfernandes-d