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

Getting "Error fetching repo, json decoding error" when running running GHOpenPR from a private repo #8

Closed
timtyrrell opened this issue May 13, 2022 · 8 comments

Comments

@timtyrrell
Copy link

timtyrrell commented May 13, 2022

On neovim 0.7 release, the PR list opens with a few PRs but when I select one it appears to fail somewhere in the process. Is there a way to enable more logging, in case that would help?

"Error fetching repo, json decoding error"

Also, when I selected a PR later:
"A pull request is already opened, close it and open pull #685?" and say "yes", I the error below:

E5108: Error executing lua ...ll/.config/nvim/plugged/gh.nvim/lua/litee/gh/pr/init.lua:363: attempt to index field 'state' (a nil value)
stack traceback:
        ...ll/.config/nvim/plugged/gh.nvim/lua/litee/gh/pr/init.lua:363: in function 'close_pull'
        ...ll/.config/nvim/plugged/gh.nvim/lua/litee/gh/pr/init.lua:213: in function 'on_choice'
        ...e-ui-select.nvim/lua/telescope/_extensions/ui-select.lua:122: in function 'run_replace_or_original'
        ...nvim/plugged/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
        ...g/nvim/plugged/telescope.nvim/lua/telescope/mappings.lua:242: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

Not sure if the last one was related to already being on the PR branch or not.

From this reddit thread

@ldelossa
Copy link
Owner

Does the status bar leave any clue as to where it fails? We log out each step while its occuring

@ldelossa
Copy link
Owner

@timtyrrell are you using the latest plugin? I'm not seeing anywhere I log "Error fetching repo"

~/.config/nvim/after/gh.nvim aggregated-file-view*
🖭  ag "Error fetching repo"

@ldelossa
Copy link
Owner

Okay I think I know what the issue here is.

gh cli --paginate returns a json stream of data, not a single array with all items.

Neovim's json decoding doesn't know how to deal with this. So when large requests are made that trigger a pagination, the decoder gets a stream and it crashes.

For now, I'll remove the pagination flags from the CLI, but we won't be retreiving all possible data. I made a comment on an issue here which would be the ideal fix: cli/cli#1268 (comment)

I think we can also whip up a poor-mans pagination function which just does "keep requesting data until the array I recieve is empty". But that's assuming the GH API returns empty arrays when the offset requests are larger then the number of items that could be returned. Tho, i guess if it errors hopefully it errors with a specific value and we can catch for it.

@ldelossa
Copy link
Owner

@timtyrrell 2cfd82d

Latest commit should at least get everything working for now. I'll start to see how we can paginate requests to get all the data.

@timtyrrell
Copy link
Author

@ldelossa just tried, I was able to get a PR open now 👍

@ldelossa
Copy link
Owner

awesome. we'll keep this issue open until pagination is figured out.

@ldelossa
Copy link
Owner

@timtyrrell you can try this branch out, right now there should be a debug log that shows its paginating any resources that return 100 items. https://github.com/ldelossa/gh.nvim/pull/12/files

This isn't done for review threads yet, pagination in GraphQL seems really annoying... so I'm gonna look at that a bit later.

@ldelossa
Copy link
Owner

Closing this out, pagination is implemented at this point.

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

No branches or pull requests

2 participants