Skip to content

Host validation #9598

@kommendorkapten

Description

@kommendorkapten

This issue is a response to a discussion in another pr, see this thread for details: #9542 (comment)

Hostnames are managed in different ways, they can either be part of a ORG/REPO string, GH_HOST environment variable, or be set in the config file. There is no general validation of that validity of the actual hostname, and this can lead to inconsistent error reporting.

We should make sure that hostnames are validated centrally (e.g. in auth.DefaultHost() by calling ghainstance.HostnameValidator()). For commands that are accepting hosts via different means, should also call ghainstanceHostnameValidator() before using the host.

An example of where host validation does not happen:

$  GH_HOST='foo$bar.com' gh issue list
none of the git remotes configured for this repository correspond to the GH_HOST environment variable. Try adding a matching remote or unsetting the variable.

Expected here would be a message similar to foo$bar.com is not a valid hostname.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions