antfu-collective/sponsorkit

GitHub Tier is null

jycouet opened this issue · 7 comments

Describe the bug

When I launch sponsorkit, I get this error:

TypeError: Cannot read properties of null (reading 'isOneTime')
    at xxx/node_modules/.pnpm/sponsorkit@0.9.1/node_modules/sponsorkit/dist/index.cjs:478:25

Looking more into it, it seems that GitHub is returning null to the tier field now!

query {
  organization(login: "MY_ORG") {
    sponsorshipsAsMaintainer(first: 100) {
      totalCount
      pageInfo {
        endCursor
        hasNextPage
      }
      nodes {
        createdAt
        privacyLevel
        tier {             # <-- This field is null
          name
          isOneTime
          monthlyPriceInCents
          monthlyPriceInDollars
        }
        sponsorEntity {
          __typename
          ...on Organization {
            login
            name
            avatarUrl
            websiteUrl
          }
          ...on User {
            login
            name
            avatarUrl
            websiteUrl
          }
        }
      }
    }
  }
}

I did check in the online https://docs.github.com/en/graphql/overview/explorer of github, and yes, I get all sponsors, but no tier information (it's null).

I don't know from when, as it was working well before 👍
Any idea of where to ask for GitHub API changes ?

Should this case of tier null be handle? (I could do a PR, but I'm not sure it's wanted... as we lose a lot of info.)
Let me know

Reproduction

https://github.com/HoudiniGraphql/sponsors

System Info

System:
    OS: macOS 14.2.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 372.11 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - ~/.nvm/versions/node/v21.2.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v21.2.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v21.2.0/bin/npm
    pnpm: 8.10.5 - ~/Library/pnpm/pnpm
    bun: 1.0.12 - ~/.bun/bin/bun
  Browsers:
    Chrome: 121.0.6167.160
    Safari: 17.2.1

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

I am having the same issue

It's most likely because of token rights I think.

I am up to provide a better error message in this case to guide users to update their token permissions. PR welcome

So what do we need to update ? Which permission is missing ?

I don't really know - I don't have such issue on my side. You might double check the docs to see if you missed anything and help us figure out what we could improve

@antfu Yes i checked ans i hâve thé 2 needed permissions. I should mention it was working 6days ago. So a new permission might be needed.

@antfu i think i found the issue. Even with the correct permissions some sponsorshipsAsMaintainer.nodes can be returned with null tier. I am not sure why this is on github side. For me only one node has null tier.
I fixed it locally by filtering nodes for non null tier.
I created a PR. Hoping you are going to accept it