lima-vm/lima · error

redirect %#q is not a `github:%s` URL (from %#q)

Error message

redirect %#q is not a `github:%s` URL (from %#q)

What it means

validateGitHubRedirect enforces that a github: redirect file found in an ORG==REPO repo points back into the same org: the first line must start with "github:<ORG>/". If it points to another org, an http(s) URL, or arbitrary text, the fetch fails with "redirect <value> is not a `github:<ORG>` URL (from <url>)". This prevents redirect files from pulling templates from arbitrary orgs.

Source

Thrown at pkg/limatmpl/github.go:235

		return "", fmt.Errorf("failed to fetch file: %w", err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return "", fmt.Errorf("file %#q not found or inaccessible: status %d", resp.Request.URL, resp.StatusCode)
	}
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return "", fmt.Errorf("failed to read %#q content: %w", resp.Request.URL, err)
	}
	return validateGitHubRedirect(string(body), org, origBranch, resp.Request.URL.String())
}

func validateGitHubRedirect(body, org, origBranch, url string) (string, error) {
	redirect, _, _ := strings.Cut(body, "\n")
	redirect = strings.TrimSpace(redirect)

	if !strings.HasPrefix(redirect, "github:"+org+"/") {
		return "", fmt.Errorf("redirect %#q is not a `github:%s` URL (from %#q)", redirect, org, url)
	}
	if strings.ContainsRune(redirect, '@') {
		return "", fmt.Errorf("redirect %#q must not include a branch/tag/sha (from %#q)", redirect, url)
	}
	// If the origBranch is empty, then we need to look up the default branch in the redirect
	if origBranch != "" {
		redirect += "@" + origBranch
	}
	return redirect, nil
}

View on GitHub (pinned to dd909d0973)

Solutions

  1. Edit the redirect file in the source repo to start with github:<ORG>/ where ORG matches the repo owner
  2. If the template moved to another org, reference the new org's repo directly instead of going through the redirect
  3. If the file is not meant to be a redirect, change its first line so it does not start with "github:"
  4. Check for org renames and update the redirect accordingly

Example fix

// redirect file first line, before
github:moved-org/templates/alpine.yaml
// after
github:lima-vm/lima/templates/alpine.yaml
Defensive patterns

Strategy: validation

Validate before calling

func validRedirect(body, org string) bool {
    line, _, _ := strings.Cut(body, "\n")
    line = strings.TrimSpace(line)
    return strings.HasPrefix(line, "github:"+org+"/")
}
// validate redirect files before relying on them

Type guard

func isSameOrgRedirect(content, org string) bool {
    if !strings.HasPrefix(content, "github:") { return false }
    line, _, _ := strings.Cut(content, "\n")
    return strings.HasPrefix(strings.TrimSpace(line), "github:"+org+"/")
}

Try / catch

url, err := transformGitHubURL(ctx, ref)
if err != nil && strings.Contains(err.Error(), "is not a `github:") {
    return fmt.Errorf("%w (hint: the redirect file must point back into the same org; reference the new org's repo directly)", err)
}

Prevention

When it happens

Trigger: resolveGitHubSymlink sees content starting with "github:" in a repo where repo==org (or resolveGitHubRedirect reads the default-branch copy) and hands it to validateGitHubRedirect; the first line's prefix does not match github:<same-org>/ — e.g. it says github:other-org/... or github:org (no slash/path).

Common situations: A redirect file updated to point to a template moved to a different org; hand-edited redirect with a typo in the org segment; a file that merely begins with the text "github:" but is not a redirect (misdetected because the file's first line looks like a URL); renamed GitHub org or account.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/8521575f532f2572. Report an issue: GitHub.