pwntester / octo.nvim

Edit and review GitHub issues and pull requests from the comfort of your favorite editor
MIT License
2.28k stars 125 forks source link

ProjectNext API is deprecated, issues wont open anymore #364

Open divramod opened 1 year ago

divramod commented 1 year ago

Issue Description

issues are not opening anymore with the message

gh: The `ProjectNext` API is deprecated in favour of the more capable `ProjectV2` API. Follow the ProjectV2 guide at https://github.blog/changelog/2022-06-23-the-new-github-issues-june-23rd-update/, to find a suitable replacement.

is this an easy fix or something more substantial?

divramod commented 1 year ago

i updated gh and now it works again.

divramod commented 1 year ago

now its giving the error message again

pwntester commented 1 year ago

Weird, I cannot reproduce it. What version of gh are you using?

divramod commented 1 year ago

hmm, i cant reproduce it too, one day later. i upgraded from 2.16 to 2.22. seemed to be a temporary issue. i'll close the issue. thx for the fast reponse!

divramod commented 1 year ago

damn, i have to reopen it. it happens again. my current suspicion is, that it could be a rate limit issue, maybe 100 requests a day to the old graphql project api are ok, but not more. today i used Octo https://github.com/orga/repo/issues/number maybe around a hundred times and now its starting to show the message again when trying to open an issue.

i had the same issue, as i had that many requests at one day some days ago.

is there maybe a quickfix for me to disable the old project api calls, so that i can use the plugin? i have forked it anyway because i needed the relative line numbering and i haven't used the project functionality until now.

edit

i experimented a little bit

pwntester commented 1 year ago

Seems like ProjectV2 is the new version to support new GH projects (table layouts). May it be the case that you are getting this error when working with a project where the new projects feature is enabled (rather than the classic one).

These new projects are not yet supported in Octo. They are quite complex (multiple layouts) so not sure how well they will fit into a terminal based application.

divramod commented 1 year ago

ah, ok. i enabled the new project api feature preview some time ago. but it hadn't taken effect, so i wasn't able to use the new project functionality. today i disabled it, but the errors are still happening. even with a new classic project and clean issues.

its awkward, that its happening on unregular intervals. the last 2 days everything was ok. today i was able to use it a lot and then it suddenly stopped working. same same as 3 days ago.

i was able to pin down the error to the issue_query in the timelineItems part. https://github.com/pwntester/octo.nvim/blob/7900dc0cd37e7bb5d4175a37c9c4c3dfb94a1f7b/lua/octo/gh/graphql.lua#L1922

the result of the query sometimes gives a null node back. something like this.

          "nodes": [
            {
              "__typename": "CrossReferencedEvent"
            },
            {
              "__typename": "LabeledEvent",
              "actor": {
                "login": "divramod"
              },
              "createdAt": "2023-01-27T19:59:22Z",
              "label": {
                "color": "1D76DB",
                "name": "user-story"
              }
            },
            null,
            {
              "__typename": "AssignedEvent"
            },
            {
              "__typename": "AssignedEvent"
            }
          ]

i fixed it in a dirty way with two little adaptions you can see here: https://github.com/divramod/octo.nvim/commit/92845353a262106a8e17343321923c7fbefd6726

is there maybe a better way?

i wanted to run the graphql query on my own with hasura. can you give me a hint on what variable to pass as endCursor?

query($endCursor: String) {
  repository(owner: "findus-immobilien", name: "findus") {
...

thx for your help and the plugin again!

pwntester commented 1 year ago

Thanks for looking into it, I put your fix on https://github.com/pwntester/octo.nvim/pull/368 can you verify it works for you (checking for vim.NIL instead of type userdata so hopefully it stills works).

I havent added your workaround to swallow the error, but will try to implement support for ProjectsV2 when time permits.

As per the endcursor, this is used for pagination. It should be an string with the first index to get. So if paginating every 100 items, and you want page 3, I think endCursor should be "300" but this is defined by gh so better check the docs.