{"record":{"id":"8521575f532f2572","repo":"lima-vm/lima","slug":"redirect-q-is-not-a-github-s-url-from-q","errorCode":null,"errorMessage":"redirect %#q is not a `github:%s` URL (from %#q)","messagePattern":"redirect %#q is not a `github:(.+?)` URL \\(from %#q\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/limatmpl/github.go","lineNumber":235,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"failed to fetch file: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"file %#q not found or inaccessible: status %d\", resp.Request.URL, resp.StatusCode)\n\t}\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to read %#q content: %w\", resp.Request.URL, err)\n\t}\n\treturn validateGitHubRedirect(string(body), org, origBranch, resp.Request.URL.String())\n}\n\nfunc validateGitHubRedirect(body, org, origBranch, url string) (string, error) {\n\tredirect, _, _ := strings.Cut(body, \"\\n\")\n\tredirect = strings.TrimSpace(redirect)\n\n\tif !strings.HasPrefix(redirect, \"github:\"+org+\"/\") {\n\t\treturn \"\", fmt.Errorf(\"redirect %#q is not a `github:%s` URL (from %#q)\", redirect, org, url)\n\t}\n\tif strings.ContainsRune(redirect, '@') {\n\t\treturn \"\", fmt.Errorf(\"redirect %#q must not include a branch/tag/sha (from %#q)\", redirect, url)\n\t}\n\t// If the origBranch is empty, then we need to look up the default branch in the redirect\n\tif origBranch != \"\" {\n\t\tredirect += \"@\" + origBranch\n\t}\n\treturn redirect, nil\n}\n","sourceCodeStart":217,"sourceCodeEnd":246,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/limatmpl/github.go#L217-L246","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Edit the redirect file in the source repo to start with github:<ORG>/ where ORG matches the repo owner","If the template moved to another org, reference the new org's repo directly instead of going through the redirect","If the file is not meant to be a redirect, change its first line so it does not start with \"github:\"","Check for org renames and update the redirect accordingly"],"exampleFix":"// redirect file first line, before\ngithub:moved-org/templates/alpine.yaml\n// after\ngithub:lima-vm/lima/templates/alpine.yaml","handlingStrategy":"validation","validationCode":"func validRedirect(body, org string) bool {\n    line, _, _ := strings.Cut(body, \"\\n\")\n    line = strings.TrimSpace(line)\n    return strings.HasPrefix(line, \"github:\"+org+\"/\")\n}\n// validate redirect files before relying on them","typeGuard":"func isSameOrgRedirect(content, org string) bool {\n    if !strings.HasPrefix(content, \"github:\") { return false }\n    line, _, _ := strings.Cut(content, \"\\n\")\n    return strings.HasPrefix(strings.TrimSpace(line), \"github:\"+org+\"/\")\n}","tryCatchPattern":"url, err := transformGitHubURL(ctx, ref)\nif err != nil && strings.Contains(err.Error(), \"is not a `github:\") {\n    return fmt.Errorf(\"%w (hint: the redirect file must point back into the same org; reference the new org's repo directly)\", err)\n}","preventionTips":["Keep redirect first lines as github:<same-ORG>/REPO/PATH","Never point redirect files at other orgs — fetch those directly","Ensure redirect files' first line actually starts with github: to avoid misclassification","Update redirects after org/account renames"],"tags":["validation","github","redirect"],"backgroundTag":"invalid-redirect-target","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}