{"record":{"id":"46178d1ef209cb2b","repo":"charmbracelet/glow","slug":"can-t-find-readme-in-gitlab-repository","errorCode":null,"errorMessage":"can't find README in GitLab repository","messagePattern":"can't find README in GitLab repository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitlab.go","lineNumber":60,"sourceCode":"\t\treturn nil, fmt.Errorf(\"unable to parse json: %w\", err)\n\t}\n\n\treadmeRawURL := strings.ReplaceAll(result.ReadmeURL, \"blob\", \"raw\")\n\n\tif res.StatusCode == http.StatusOK {\n\t\t//nolint:bodyclose\n\t\t// it is closed on the caller\n\t\tresp, err := http.Get(readmeRawURL) //nolint: gosec,noctx\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to get url: %w\", err)\n\t\t}\n\n\t\tif resp.StatusCode == http.StatusOK {\n\t\t\treturn &source{resp.Body, readmeRawURL}, nil\n\t\t}\n\t}\n\n\treturn nil, errors.New(\"can't find README in GitLab repository\")\n}\n","sourceCodeStart":42,"sourceCodeEnd":62,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/gitlab.go#L42-L62","documentation":"findGitLabREADME calls the GitLab projects API (https://{host}/api/v4/projects/{url-escaped-owner%2Frepo}), reads the readme_url field, and GETs the derived raw URL (readmeRawURL). If either request does not return HTTP 200, glow gives up with this sentinel error instead of a source reader. Like the GitHub variant, it collapses 404/403/other statuses into one message.","triggerScenarios":"glow with a gitlab.com repo URL for a project that does not exist or is private (API returns 404); GitLab returning 429/403 for heavy or anonymous traffic from one IP; the raw readme URL returning non-200 because the README was deleted or the branch renamed; self-hosted GitLab where the projects endpoint is disabled or requires auth.","commonSituations":"Private GitLab projects (glow sends no PRIVATE-TOKEN); typos in the project path; CI shared IPs being throttled by GitLab; README named with an extension GitLab's readme_url does not resolve raw.","solutions":["Verify the project URL loads in a browser and shows a README","Pass the raw file URL directly, e.g. glow https://gitlab.com/OWNER/REPO/-/raw/main/README.md","Clone the repository and run glow on the local directory or file","For self-hosted GitLab, confirm anonymous read access to /api/v4/projects/<id> with curl"],"exampleFix":"# before\nglow https://gitlab.com/owner/typod-repo\n\n# after (raw endpoint bypasses the projects API)\nglow https://gitlab.com/owner/repo/-/raw/main/README.md","handlingStrategy":"validation","validationCode":"func checkGitLabReadable(u *url.URL) error {\n\towner, repo, ok := strings.Cut(strings.TrimPrefix(u.Path, \"/\"), \"/\")\n\tif !ok {\n\t\treturn fmt.Errorf(\"invalid url: %s\", u)\n\t}\n\tapi := fmt.Sprintf(\"https://%s/api/v4/projects/%s\", u.Hostname(), url.QueryEscape(owner+\"/\"+repo))\n\tresp, err := http.Head(api)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"gitlab project endpoint returned %d (missing, private, or throttled)\", resp.StatusCode)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"src, err := findGitLabREADME(u)\nif err != nil {\n\tif err.Error() == \"can't find README in GitLab repository\" {\n\t\traw := fmt.Sprintf(\"https://%s/%s/%s/-/raw/HEAD/README.md\", u.Hostname(), owner, repo)\n\t\tsrc, err = openRawSource(raw)\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"rendering gitlab readme: %w\", err)\n\t}\n}","preventionTips":["Confirm the project is public (or clone locally) before passing GitLab URLs to glow","In automation, hit the /api/v4/projects/OWNER%2FREPO endpoint yourself first to distinguish 404 from network failure","Prefer the /-/raw/ URL form when you only need file contents — it avoids the projects API entirely"],"tags":["gitlab","http","readme","api","network"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}