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

There was an error generating sponsors. ❌ - Cannot read 'viewer' of undefined #450

Closed
adi1090x opened this issue Aug 20, 2022 · 10 comments

Comments

@adi1090x
Copy link

Failed to generate sponsors

the previous version was working fine, now i get this error after new release : Error: There was an error generating the updated file: Cannot read property 'viewer' of undefined ❌

> Run JamesIves/github-sponsors-readme-action@v1

    GitHub Sponsors Readme Action 💖

    🚀 Getting Started Guide: https://github.com/JamesIves/github-sponsors-readme-action
    ❓ Discussions / Q&A: https://github.com/JamesIves/github-sponsors-readme-action/discussions
    🔧 Report a Bug: https://github.com/JamesIves/github-sponsors-readme-action/issues

    📣 Maintained by James Ives: https://jamesiv.es/
    💖 Support: https://github.com/sponsors/JamesIves
Checking configuration and initializing… 🚚
Fetching data from the GitHub API as User… ⚽
Generating updated README.md file… 📁
Generating template… ✨
Error: There was an error generating the updated file: Cannot read property 'viewer' of undefined ❌
There was an error generating sponsors. ❌

Here's my workflow yml

File : .github/workflows/sponsors.yml

name: Generate Sponsors README
on:
  push:
    branches:
      - master
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v2

      - name: Generate Sponsors 💖
        uses: JamesIves/github-sponsors-readme-action@v1
        with:
          token: ${{ secrets.PAT_GHS }}
          file: 'README.md'

      - name: Deploy to GitHub Pages 🚀
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          branch: master
          folder: '.'

PAT has a scope user:read as well.
Is this a bug in new release, or I'm doing something wrong here?

@JamesIves
Copy link
Owner

JamesIves commented Aug 20, 2022

Are you fetching as a user or an organization? The two scopes I've provided my action are read:user and read:org which works. There was an issue in a previous version that made it so you couldn't fetch sponsors if they were part of an organization, so you may need to bump the permissions slightly as this has been addressed. I've updated the documentation to address this so it's clearer. Apologies if this has caused any problems, it probably should have been a major version change.

If you are fetching sponsors as an organization account, you must provide the action with organization: true as viewer is used for user level accounts.

@adi1090x
Copy link
Author

adi1090x commented Aug 20, 2022

Hello @JamesIves

I'm fetching as a user. Still not sure what's causing that. It only started happening after the new release. Before that (probably 5 days ago) it was working just fine (with same yml and PAT)

@JamesIves
Copy link
Owner

JamesIves commented Aug 20, 2022

Can you share the permission levels of your PAT? Is it scoped as read:user and read:org? The new release requires additional scope.

@adi1090x
Copy link
Author

Share the permission levels (how?)

That's the only selected scope for my PAT.
Screenshot_2022-08-21-11-50-13_1920x1080

I do also have an organization (But why should it matter, The repository is in my user profile, Not in organization)

@adi1090x
Copy link
Author

Also doesn't work on these scopes as well
Screenshot_2022-08-21-11-45-10_1920x1080
.

@JamesIves
Copy link
Owner

JamesIves commented Aug 21, 2022

By sharing I meant providing screenshots of the permission levels.

The read:org permission is required as the action requests Organization in the GraphQL query, this is done so if an organization user sponsors you it will show up in your list of sponsors, the bug this fixed was causing organization sponsors to a user account to not show up. If you're trying to populate a list of sponsors as an organization account you'd provide the same permission scope but you'd also set the organization parameter in the workflow to true.

The action requires read only permission to user and org even as a user account. Can you please try selecting read:user and read:org and try again?

@adi1090x
Copy link
Author

Yes, That worked!

Apparently, the action now needs both scopes.

Thank you.

@JamesIves JamesIves changed the title There was an error generating sponsors. ❌ There was an error generating sponsors. ❌ - Cannot read 'viewer' of undefined Aug 22, 2022
@JamesIves JamesIves pinned this issue Aug 22, 2022
@JamesIves
Copy link
Owner

I'm glad that worked! Pinning for visibility.

@vitalets
Copy link

The action requires read only permission to user and org even as a user account.

This should definitely be highlighted in docs and in error message!
As now it looks like If you want sponsors for user account request only user:read permission.

@JamesIves
Copy link
Owner

It is mentioned several times 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants