Commit graph

34 commits

Author SHA1 Message Date
William Martin
3921788f76
Revert "fix: clarify scope error while creating issues for projects" 2026-03-12 12:55:55 +01:00
Kynan Ware
e725e38370
Merge pull request #12596 from elijahthis/fix/clarify-scope-error
fix: clarify scope error while creating issues for projects
2026-03-02 11:12:35 -07:00
William Martin
166db75d36 pin REST API version to 2022-11-28
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-13 19:46:16 +01:00
elijahthis
71564fd4a1 test: TestGenerateScopeErrorForGQL and TestRequiredScopesFromServerMessage 2026-02-01 23:26:03 +01:00
Sam Coe
ebcf3a1022
Set default Accept header for api command when one is not specified (#8303) 2023-11-06 15:22:32 +01:00
Sam Coe
9d70d62520
Set blank headers so they are not automatically resolved by go-gh (#5935) 2022-07-14 14:13:34 +02:00
Sam Coe
074ed50b8a
Integrate go-gh API package (#5614) 2022-06-23 04:05:31 +01:00
Håvard Anda Estensen
58cb773e09
Replace ioutil with io and os (#5498) 2022-04-26 13:07:44 +02:00
Des Preston
8f9548fd37
Ignore scope suggestions for http 422 (#4809)
HTTP 422 messages are for validation errors, but OAUTH permissions
suggestions get printed anyways. Most times, the user probably has the
right permissions. This fix adds the check to avoid printing a confusing
message.

Co-authored-by: Mislav Marohnić <mislav@github.com>
2021-12-01 18:13:48 +00:00
Mislav Marohnić
34fc5fb75c Improve issue view re: overfetching, PR support
- Supports passing a PR as argument, not just issues
- Makes it non-fatal when project cards were not able to load
- Cleans up legacy method for fetching issues
2021-11-24 18:49:36 +01:00
Mislav Marohnić
07cad386a5 Improve issue close re: overfetching, handling PRs
- `issue close` no longer fetches all issue fields and thus avoids the
  problem when loading failed due to token not having access to projects

- `issue close` now accepts either issue or pull number as argument.
2021-11-23 19:38:55 +01:00
Mislav Marohnić
2ca18e0600 Warn about missing OAuth scopes when reporting HTTP 4xx errors
If a 4xx server response lists scopes in the X-Accepted-Oauth-Scopes
header that are not present in the X-Oauth-Scopes header, the final
error messaging on stderr will now include a hint for the user that they
might need to request the additional scope:

    $ gh codespace list
    error getting codespaces: HTTP 403: Must have admin rights to Repository. (https://api.github.com/user/codespaces?per_page=30)
    This API operation needs the "codespace" scope. To request it, run:  gh auth refresh -h github.com -s codespace
2021-10-13 23:24:14 +02:00
Mislav Marohnić
11fbb60ae7 Rename the module to "github.com/cli/cli/v2" 2021-08-25 12:41:30 +02:00
Mislav Marohnić
3e23dcab15 Fix HTTP 502 error reporting from GraphQL request
Now it makes sure that the message portion will be printed to stderr
when the user encounters the error.
2021-08-18 22:17:32 +02:00
Mislav Marohnić
ac348b0dec Fix requesting REST sub-resources on GHE
GitHub REST resources typically return full URLs to fetch related
resources at. We used to parse those URLs to find just the path portion
and pass that in to the `REST()` function, which only accepted paths. By
doing so, we are essential de-constructing a URL just to re-assemble it
again. While re-assembling it for Enterprise, though, we would
accidentally inject an extra `api/v3/` prefix where one was not needed.

The solution is just to use raw URLs as reported by the REST API with
no modifications. This extends the `REST()` function to accept full URLs
in addition to just paths to resources.
2021-04-19 12:41:09 +02:00
Mislav Marohnić
5a110c8e42 Add SSH key generation & uploading to gh auth login flow 2021-02-01 23:34:00 +01:00
Mislav Marohnić
75ebb863e3 Use testify assertions for error matching 2021-01-19 13:59:37 +01:00
Cristian Dominguez
45f4a1f087 Equal: flip arguments position 2021-01-18 21:00:59 -03:00
Cristian Dominguez
3afb1d0b1a Use Testify assertions in test 2021-01-16 19:19:30 -03:00
Cristian Dominguez
ce151420f3 Migrate legacy tests 2021-01-11 21:07:19 -03:00
Mislav Marohnić
53cea2667e Support "integration" tokens
Integration tokens are different than OAuth token in it that they don't report any `X-Oauth-Scopes` in response headers.
2020-10-16 17:11:14 +00:00
Mislav Marohnić
626be2a095 Fix formatting in MissingScopesError 2020-10-16 17:11:10 +00:00
Mislav Marohnić
38f0f607e9 🔥 outdated CheckScopes 2020-10-16 17:10:23 +00:00
Mislav Marohnić
a00d927970 Add release download, upload files on create, upload retrying 2020-08-21 18:00:52 +02:00
Mislav Marohnić
288d01318b Respect the hostname of current repository in queries 2020-07-23 22:31:08 +02:00
Mislav Marohnić
2086ecb3d1 Fix printing network error in case for failed HTTP requests
The CheckScopes middleware tried to read from `res.Headers` before it
verified that `res` is available.
2020-07-17 18:24:13 +02:00
Mislav Marohnić
28cd348176 Only check OAuth scopes when X-Oauth-Scopes header is present 2020-07-13 15:53:53 +02:00
Mislav Marohnić
55d31303ea Have admin:org scope satisfy read:org requirement
`admin:org` is inclusive of `read:org`, so if we find the former listed
in response headers, we can conclude that the token has necessary scopes
instead of letting a warning notice be shown.
2020-07-13 15:35:14 +02:00
Mislav Marohnić
1ca3d171e6 Tweak HTTP 422 handling when deleting branches 2020-06-30 19:21:39 +02:00
Pavel Borzenkov
c66eebc6fb api: return structured error for failed API calls
`fmt.Errorf` hides information and makes it hard to test for specific
conditions in returned error. Return a structured error instead.

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
2020-06-27 18:47:34 +03:00
Mislav Marohnić
0a4d4ee007 Replace FakeHTTP with httpmock which is now compatible 2020-05-07 15:19:14 +02:00
gertd
203525c031 pr bug/rest-204 review feedback 2020-04-10 16:48:11 -07:00
Mislav Marohnić
6c49614db7 Fix tests 2020-01-21 22:56:15 +01:00
Mislav Marohnić
862db45587 Add mising files 2019-10-29 21:19:34 +01:00