MCPcopy Create free account
hub / github.com/github/gh-aw / hostResolutionHintForNotFound

Function hostResolutionHintForNotFound

pkg/cli/fetch.go:214–240  ·  view source on GitHub ↗

hostResolutionHintForNotFound returns a user-facing hint and whether it is applicable. hasHint is true only for 404-style resolution failures on non-github.com hosts.

(owner, repo, ref, workflowPath, explicitHost string, err error)

Source from the content-addressed store, hash-verified

212// hostResolutionHintForNotFound returns a user-facing hint and whether it is applicable.
213// hasHint is true only for 404-style resolution failures on non-github.com hosts.
214func hostResolutionHintForNotFound(owner, repo, ref, workflowPath, explicitHost string, err error) (hint string, hasHint bool) {
215 if err == nil {
216 return "", false
217 }
218
219 errorText := strings.ToLower(err.Error())
220 if !strings.Contains(errorText, "http 404") && !strings.Contains(errorText, "status 404") {
221 return "", false
222 }
223
224 normalizedExplicitHost := normalizeHostForHint(explicitHost)
225 if normalizedExplicitHost != "" {
226 return "", false
227 }
228
229 resolvedHost := normalizeHostForHint(getGitHubHost())
230 if resolvedHost == "" || resolvedHost == "github.com" {
231 return "", false
232 }
233
234 trimmedPath := strings.TrimPrefix(workflowPath, "/")
235 fullURL := fmt.Sprintf("https://github.com/%s/%s/blob/%s/%s", owner, repo, ref, trimmedPath)
236 return fmt.Sprintf(
237 "Shorthand specs resolved on %s. Try using a full github.com source URL instead (for example: gh aw add %s)",
238 resolvedHost, fullURL,
239 ), true
240}
241
242func normalizeHostForHint(host string) string {
243 host = strings.TrimSpace(strings.ToLower(host))

Callers 2

Calls 4

normalizeHostForHintFunction · 0.85
getGitHubHostFunction · 0.85
ToLowerMethod · 0.80
ErrorMethod · 0.45

Tested by 1