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

Handle errors when parsing hostname in auth flow #9729

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

BagToad
Copy link
Member

@BagToad BagToad commented Oct 8, 2024

Fixes #9248

Demo

❯ ./bin/gh auth login
? Where do you use GitHub? Other
? Hostname: invalid url for github
? What is your preferred protocol for Git operations on this host? HTTPS
? Authenticate Git with your GitHub credentials? No
? How would you like to authenticate GitHub CLI? Login with a web browser
failed to authenticate via web browser: parse "https://invalid url for github/": invalid character " " in host name

Notes

  • Needed to update go.mod to use github.com/cli/[email protected] for new NewGitHubHost function that returns an err.
  • This file doesn't have any tests currently, and at face value it seems like we'd need to refactor to properly test. Should adding tests to this file to be within scope of this PR, or can we just consider this a small bug fix and avoid a larger refactor?

@BagToad BagToad requested a review from a team as a code owner October 8, 2024 22:24
@BagToad BagToad requested a review from jtmcg October 8, 2024 22:24
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Oct 8, 2024
@BagToad BagToad removed the external pull request originating outside of the CLI core team label Oct 8, 2024
Copy link
Member

@williammartin williammartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I checked your reproduction, and also checked that the usual flow still looked good.

I did commit on top with cli/[email protected] because v1.1.0 had a minor regression. Though it didn't affect us, it just seemed reasonable to bump while we were at it. Hope that's ok with you 🙏

@williammartin williammartin merged commit 76ea939 into trunk Oct 9, 2024
16 checks passed
@williammartin williammartin deleted the kw/cli-9248-handle-error-in-hostname-parsing branch October 9, 2024 11:43
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Oct 17, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.58.0` -> `v2.59.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.59.0`](https://github.com/cli/cli/releases/tag/v2.59.0): GitHub CLI 2.59.0

[Compare Source](cli/cli@v2.58.0...v2.59.0)

#### What's Changed

-   Allow community submitted design work by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9683
-   Improve `SECURITY.md` with expectations for privately reported vulnerabilities by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9687
-   Emit a log message when extension installation falls back to a `darwin-amd64` binary on an Apple Silicon macOS device by [@&#8203;timrogers](https://github.com/timrogers) in cli/cli#9650
-   Print the login URL even when opening a browser by [@&#8203;ulfjack](https://github.com/ulfjack) in cli/cli#7091
-   configurable maxwidth for markdown WithWrap() by [@&#8203;smemsh](https://github.com/smemsh) in cli/cli#9626
-   Handle errors when parsing hostname in auth flow by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9729
-   Add `repo license list/view` and `repo gitignore list/view` by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9721
-   Introduce testscript acceptance tests generally, and for the MR command specifically by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9745
-   Support `GH_ACCEPTANCE_SCRIPT` env var to target a single script by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9756
-   Ensure Acceptance defer failures are debuggable by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9754
-   Add acceptance task to makefile by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9748
-   Add Acceptance tests for `issue` command by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9757
-   Update IsEnterprise and IsTenancy for orthogonality using go-gh by [@&#8203;jtmcg](https://github.com/jtmcg) in cli/cli#9755
-   Supporting filtering on `gist list` by [@&#8203;heaths](https://github.com/heaths) in cli/cli#9728

#### New Contributors

-   [@&#8203;ulfjack](https://github.com/ulfjack) made their first contribution in cli/cli#7091
-   [@&#8203;smemsh](https://github.com/smemsh) made their first contribution in cli/cli#9626

**Full Changelog**: cli/cli@v2.58.0...v2.59.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
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

Successfully merging this pull request may close these issues.

GitHub CLI gh auth login Panic on Invalid Hostname Input
3 participants