cli/cli · warning
a value is required
Error message
a value is required
What it means
Returned (as *NotFoundError) when the PR finder has neither a PR number/URL nor a usable (base repo + branch name) pair to search with. It is a typed NotFoundError, so callers can distinguish 'not found' from hard failures. It usually means the command cannot even formulate a query.
Source
Thrown at internal/ghinstance/host.go:38
// Default returns the host name of the default GitHub instance.
func Default() string {
return defaultHostname
}
// TenantName extracts the tenant name from tenancy host name and
// reports whether it found the tenant name.
func TenantName(h string) (string, bool) {
normalizedHostName := ghauth.NormalizeHostname(h)
return strings.CutSuffix(normalizedHostName, "."+tenancyHost)
}
func isGarage(h string) bool {
return strings.EqualFold(h, "garage.github.com")
}
func HostnameValidator(hostname string) error {
if len(strings.TrimSpace(hostname)) < 1 {
return errors.New("a value is required")
}
if strings.ContainsRune(hostname, '/') || strings.ContainsRune(hostname, ':') {
return errors.New("invalid hostname")
}
return nil
}
func GraphQLEndpoint(hostname string) string {
if isGarage(hostname) {
return fmt.Sprintf("https://%s/api/graphql", hostname)
}
if ghauth.IsEnterprise(hostname) {
return fmt.Sprintf("https://%s/api/graphql", hostname)
}
if strings.EqualFold(hostname, localhost) {
return fmt.Sprintf("http://api.%s/graphql", hostname)
}
return fmt.Sprintf("https://api.%s/graphql", hostname)View on GitHub (pinned to 0eeec0b92e)
Solutions
- Pass an explicit selector: `gh pr view 123`, `gh pr view https://github.com/o/r/pull/123`, or `--repo owner/repo`.
- Ensure you are inside the repository checkout and on a branch: `git rev-parse --abbrev-ref HEAD`.
- Detect this case in code with errors.As(err, &NotFoundError{}) instead of string matching.
Example fix
# before gh pr view # in a non-repo dir -> no pull requests found # after gh pr view --repo acme/widgets 123
Defensive patterns
Strategy: type-guard
Validate before calling
if selector == "" && branchName == "" {
return errors.New("no PR selector and no branch context: pass a number, URL, or --repo")
} Type guard
func isNotFound(err error) bool {
var nf *shared.NotFoundError
return errors.As(err, &nf)
} Try / catch
pr, repo, err := finder.Find(opts)
if err != nil {
var nf *shared.NotFoundError
if errors.As(err, &nf) {
// not-found: create the PR or prompt, do not report a hard error
}
return err
} Prevention
- Always pass an explicit selector in scripts.
- Ensure the working directory is a git checkout on a branch.
- Branch on the typed NotFoundError rather than matching message strings.
When it happens
Trigger: Running `gh pr view/status/checkout` style commands with no argument where: the current directory is not a git repo (no branch name), no base repo can be resolved, and no selector was given. Also when branchName is empty (detached HEAD).
Common situations: Running gh outside a git repository; detached HEAD in CI; scripts that assume a branch context that does not exist.
Related errors
- a task description is required
- empty Copilot API URL returned
- cannot use `--stdio` with `--server-port`
- cannot use `--stdio` with `--profile`
- cannot use `--config` with `--profile`
AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15).
Data as JSON: /api/errors/bf63088a8ed75449.
Report an issue: GitHub.