xtekky/gpt4free · warning · VersionNotFoundError

No tag_name found in latest GitHub release for '{repo}'

Error message

No tag_name found in latest GitHub release for '{repo}'

What it means

get_github_version in g4f/version.py raises VersionNotFoundError with this message when the GitHub API responded successfully (HTTP 2xx) but the JSON body has no 'tag_name' key — i.e. the 'latest release' endpoint returned an object without a release tag. The check happens before the generic except clause rewraps other failures.

Source

Thrown at g4f/version.py:57

@lru_cache(maxsize=1)
def get_github_version(repo: str) -> str:
    """
    Retrieves the latest release version from a GitHub repository.

    Raises:
        VersionNotFoundError: If there is a network or parsing error.
    """
    try:
        import requests

        response = requests.get(
            f"https://api.github.com/repos/{repo}/releases/latest",
            timeout=REQUEST_TIMEOUT,
        )
        response.raise_for_status()
        data = response.json()
        if "tag_name" not in data:
            raise VersionNotFoundError(
                f"No tag_name found in latest GitHub release for '{repo}'"
            )
        return data["tag_name"]
    except Exception as e:
        raise VersionNotFoundError(
            f"Failed to get GitHub release version for '{repo}'"
        ) from e


def get_git_version() -> str | None:
    """Return latest Git tag if available, else None."""
    try:
        return check_output(
            ["git", "describe", "--tags", "--abbrev=0"], text=True, stderr=PIPE
        ).strip()
    except (CalledProcessError, FileNotFoundError):
        return None

View on GitHub (pinned to 973504e177)

Solutions

  1. Confirm the repo actually has a published (non-prerelease, non-draft) release — create one or use tags instead
  2. Verify the repo slug passed to get_github_version is correct (owner/name)
  3. Catch VersionNotFoundError and treat the GitHub check as optional (fall back to PyPI or git tag versioning)
  4. Note the result is lru_cache'd — restart the process after fixing the repo so a stale failure is not reused

Example fix

# before
v = get_github_version('xtekky/gpt4free')  # raises if no tag_name

# after
from g4f.version import get_github_version, VersionNotFoundError
try:
    v = get_github_version('xtekky/gpt4free')
except VersionNotFoundError:
    v = get_git_version()  # or None
Defensive patterns

Strategy: try-catch

Validate before calling

import requests

def github_release_has_tag(repo: str) -> bool:
    r = requests.get(f"https://api.github.com/repos/{repo}/releases/latest", timeout=5)
    r.raise_for_status()
    return "tag_name" in r.json()

Try / catch

from g4f.version import get_github_version, VersionNotFoundError

try:
    tag = get_github_version(repo)
except VersionNotFoundError:
    tag = None  # repo may have no releases; fall back to git tags

Prevention

When it happens

Trigger: Calling get_github_version(repo) (memoized via lru_cache) for a repository whose /releases/latest response lacks tag_name: repos with no published releases can return an empty object, or an API change/HTML error page parsed as JSON without the key.

Common situations: Checking a fork or private/renamed repo with zero releases; GitHub returning an unexpected payload during an incident; a custom GITHUB_API base or intercepted connection returning different JSON.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/5b52abcd930e98c8. Report an issue: GitHub.