pwntester / octo.nvim

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

Can't add comments when github API does not return patches #500

Open marcomayer opened 4 months ago

marcomayer commented 4 months ago

Issue Description

Type: bug report

Describe what happened (or what feature you want)

This is probably somewhere between a bug report and a feature request.

I did run into the issue of not being able to add a comment while being in a valid diff getting the error (init.lua:309: bad argument #1 to 'ipairs' (table expected, got nil). Looked into it further and found out it's because there is no patch, looked at what is returned from gh and manually ran the gh command gh api --paginate repos/org/some-api/pulls/804/files --jq . -H "Accept: application/vnd.github.v3+json;application/vnd.github.squirrel-girl-preview+json;application/vnd.github.comfort-fade-preview+json;application/vnd.github.bane-preview+json".

What was returned by the API is "status": modified but it did contain no "patch". I stopped here but assume that some limit might have been hit on githubs API as it's a huge PR with lots of changes in testfiles etc.

The question is how to handle it and one idea maybe would be to check if status modified got returned and if so specifically query the diff for that file again if it didn't contain a patch?

Maybe this is a known issue and there's a solution/workaround for this?

Describe what you expected to happen

Comment should work even for large PRs.

If there's no path returned from API, try fetching it explicitly again for the file where it's missing. Or have an option to trust the local diff and add the comment based on the local diff?

How to reproduce it (as minimally and precisely as possible)

  1. Open a huge PR (mine got 60 changed files with ~4000 new lines and ~3000 lines deleted, gh API request having 1083737 bytes.
  2. Start review
  3. Try adding comment in one of the last files.

Tell us your environment

Ubuntu, latest stable nvim, latest octo