{"record":{"id":"63555e005c15a4d4","repo":"mislav/hub","slug":"unable-to-find-release-with-tag-name-s","errorCode":null,"errorMessage":"Unable to find release with tag name `%s'","messagePattern":"Unable to find release with tag name `(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"github/client.go","lineNumber":373,"sourceCode":"\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn\n}\n\nfunc (client *Client) FetchRelease(project *Project, tagName string) (*Release, error) {\n\treleases, err := client.FetchReleases(project, 100, func(release *Release) bool {\n\t\treturn release.TagName == tagName\n\t})\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(releases) < 1 {\n\t\treturn nil, fmt.Errorf(\"Unable to find release with tag name `%s'\", tagName)\n\t}\n\treturn &releases[0], nil\n}\n\nfunc (client *Client) CreateRelease(project *Project, releaseParams *Release) (release *Release, err error) {\n\tapi, err := client.simpleAPI()\n\tif err != nil {\n\t\treturn\n\t}\n\n\tres, err := api.PostJSON(fmt.Sprintf(\"repos/%s/%s/releases\", project.Owner, project.Name), releaseParams)\n\tif err = checkStatus(201, \"creating release\", res, err); err != nil {\n\t\treturn\n\t}\n\n\trelease = &Release{}\n\terr = res.Unmarshal(release)\n\treturn","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/github/client.go#L355-L391","documentation":"FetchRelease lists releases filtered by tag name and returns this error when the resulting slice is empty, i.e. no release on the repository matches the given tag. Note GitHub distinguishes tags from releases: a tag can exist with no published release attached.","triggerScenarios":"Calling FetchRelease(project, tagName) where the repo has zero releases with that exact tag name — the tag was never released, the release is a draft (not visible to the token), or the tag name case/prefix doesn't match exactly (e.g. `1.2.0` vs `v1.2.0`).","commonSituations":"Automating downloads of release assets for a version string that has no matching published release; CI deploying 'latest' before the release step ran; releases kept as drafts until QA; repo using tags without creating GitHub Releases.","solutions":["Confirm the exact release tag on the repo (`gh release list`) and use that string, including any `v` prefix.","If the release is a draft, publish it or use a token with access to view drafts (drafts are only visible to collaborators).","Create the release for the tag: `gh release create <tag>` if it should exist.","Add a fallback in code to list all releases and match semantically rather than by exact tag string."],"exampleFix":"// before\nrel, err := client.FetchRelease(project, tagName) // fails on \"1.2.0\" vs \"v1.2.0\"\n// after\ntagName = tagName\nif !strings.HasPrefix(tagName, \"v\") { tagName = \"v\" + tagName }\nrel, err := client.FetchRelease(project, tagName)","handlingStrategy":"validation","validationCode":"releases, _, err := api.Client.Repositories.ListReleases(ctx, owner, name, nil)\nif err != nil { return err }\nfound := false\nfor _, r := range releases { if r.GetTagName() == tagName { found = true } }\nif !found { return fmt.Errorf(\"no release for tag %s\", tagName) }","typeGuard":null,"tryCatchPattern":"rel, err := client.FetchRelease(project, tagName)\nif err != nil && strings.Contains(err.Error(), \"Unable to find release\") {\n    return fmt.Errorf(\"tag %q has no published release; run: gh release create %s\", tagName, tagName)\n}","preventionTips":["Match the exact tag string including any `v` prefix.","Publish releases instead of leaving them as drafts before automating against them.","Remember tags != releases: create a Release object for the tag.","Preflight by listing releases and matching semantically."],"tags":["github-api","releases","not-found"],"backgroundTag":"github-release-not-found","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}