timothyandrew/gh-stack

missing field `items`

Opened this issue · 11 comments

Hello,

Love the idea and look forward to using this.

I am getting the following error when trying to run gh-stack annotate:

bash-3.2$ gh-stack annotate "feature"    
Error: reqwest::Error { kind: Decode, source: Error("missing field `items`", line: 1, column: 80) }

I don't know a ton about rust but looks like a request is returning an invalid response.

Thanks!

@aschade92 were you able to figure this out, running into the same thing.

@luqven nah, I'm not a rust expert so after 30 minutes of debugging I posted this issue and forgot about it.

@luqven nah, I'm not a rust expert so after 30 minutes of debugging I posted this issue and forgot about it.

Got it thanks anyway!

@aschade92 I'm fairly certain this error pertains to the GH token. If you didn't add it to the PATH and or copy-pasted it wrong you'll see this error. I was just able to fix this.

@timothyandrew I think you're good to close this. I would just add a section, FAQ maybe, to the README.md about this error.

Were you able to successfully use the app? I tried setting the gh token using a variety of methods and did not have much luck.

Yup I was @aschade92 . I had an extra '$' in front of my token, which is why this was breaking.

Once I made certain to copy my token exactly as GH displayed it everything worked fine.

Out of curiosity, are you building the app from source or using the one on cargo? Also, what's the expiry date on your token?

I'm getting a similar error, except it's Error("missing field `id`"

I know the token is valid because the request below works fine...

curl \
  -H "Accept: application/vnd.github.v3+json" \
  -H "Authorization: token $GHSTACK_OAUTH_TOKEN" \
  'https://api.github.com/search/issues?q="foo"%20in:title,body'

Installed from source. Not really familiar with the rust toolchain so not sure how to debug further.

Full error is

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: reqwest::Error { kind: Decode, source: Error("missing field `id`", line: 1, column: 109) }', /home/ped/.cargo/registry/src/github.com-1ecc6299db9ec823/gh-stack-0.1.6/src/api/search.rs:115:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm getting a similar error, except it's Error("missing field `id`"

I know the token is valid...

You're 💯 right @p3drosola .

The issue stems from the search endpoint being used.

"https://api.github.com/search/issues",

This endpoint searches across all GH repos. Therefore, if your identifier, i.e. [f1] isn't unique enough. The response JSON, which is limited to 30 results atm I believe, will include irrelevant results and might not include your PRs at all. Often, the PRs list that is generated won't allow you to annotate or rebase since your token doesn't have read/write permissions on that repo.

To solve this use PR identifiers with more unique names, i.e. [username-f1]. That way you can run gh-stack annotate 'username-f1' and it should work.

@luqven yeah I noticed that as well after a bit more testing. I was thinking of opening a PR with a --repo flag that would add that filter to the search.. what do you think?

Thanks for your work on this mate, It's already helping my out :)

@p3drosola I can't take any credit. I've just been hacking some features on top of all the great work here.

I added a '--repo' in my fork 😜, https://github.com/luqven/gh-stack So feel free to use/PR there. Idk if PRs are being accepted here at the moment.

I've got the problem that the following successfully finds my PRs tagged with foo

curl \
  -H "Accept: application/vnd.github.v3+json" \
  -H "Authorization: token $GHSTACK_OAUTH_TOKEN" \
  'https://api.github.com/search/issues?q="foo"%20in:title,body'

but running gh-stack annotate 'foo' results in

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: reqwest::Error { kind: Decode, source: Error("invalid type: null, expected a string", line: 1, column: 1643) }', /Users/allyson/.cargo/registry/src/github.com-1ecc6299db9ec823/gh-stack-0.1.6/src/api/search.rs:115:26
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Has anyone encountered this?