{"record":{"id":"5b29f45ceb8c7493","repo":"xtekky/gpt4free","slug":"failed-to-get-github-release-version-for-repo","errorCode":null,"errorMessage":"Failed to get GitHub release version for '{repo}'","messagePattern":"Failed to get GitHub release version for '(.+?)'","errorType":"exception","errorClass":"VersionNotFoundError","httpStatus":null,"severity":"warning","filePath":"g4f/version.py","lineNumber":62,"sourceCode":"    Raises:\n        VersionNotFoundError: If there is a network or parsing error.\n    \"\"\"\n    try:\n        import requests\n\n        response = requests.get(\n            f\"https://api.github.com/repos/{repo}/releases/latest\",\n            timeout=REQUEST_TIMEOUT,\n        )\n        response.raise_for_status()\n        data = response.json()\n        if \"tag_name\" not in data:\n            raise VersionNotFoundError(\n                f\"No tag_name found in latest GitHub release for '{repo}'\"\n            )\n        return data[\"tag_name\"]\n    except Exception as e:\n        raise VersionNotFoundError(\n            f\"Failed to get GitHub release version for '{repo}'\"\n        ) from e\n\n\ndef get_git_version() -> str | None:\n    \"\"\"Return latest Git tag if available, else None.\"\"\"\n    try:\n        return check_output(\n            [\"git\", \"describe\", \"--tags\", \"--abbrev=0\"], text=True, stderr=PIPE\n        ).strip()\n    except (CalledProcessError, FileNotFoundError):\n        return None\n\n\nclass VersionUtils:\n    \"\"\"\n    Utility class for managing and comparing package versions of 'g4f'.\n    \"\"\"","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/version.py#L44-L80","documentation":"The catch-all branch of get_github_version in g4f/version.py wraps any exception raised while fetching https://api.github.com/repos/{repo}/releases/latest — network errors, non-2xx statuses from raise_for_status(), JSON decode errors — into VersionNotFoundError('Failed to get GitHub release version for \\'{repo}\\''). The inner 'No tag_name' raise is also caught here, so both paths surface with this message.","triggerScenarios":"Calling get_github_version(repo) when offline, DNS fails, a proxy blocks api.github.com, GitHub returns 403 (rate limit: 60 req/hr unauthenticated) or 404 (wrong repo slug), or the body is not valid JSON.","commonSituations":"Unauthenticated GitHub API rate limits hit by frequent update checks; CI runners with restricted egress; typos in the repo name; GitHub API outages.","solutions":["Curl the endpoint to see the real cause: curl -i https://api.github.com/repos/<repo>/releases/latest (403 = rate limit, 404 = bad repo)","If rate-limited, add a GITHUB_TOKEN-authenticated request or check less frequently","Fix the repo slug if it 404s","Catch VersionNotFoundError and degrade gracefully to another version source (PyPI/git tags)"],"exampleFix":"# before\nlatest = get_github_version('xtekky/gpt4free')\n\n# after\nfrom g4f.version import get_github_version, VersionNotFoundError\ntry:\n    latest = get_github_version('xtekky/gpt4free')\nexcept VersionNotFoundError as e:\n    latest = None  # log e.__cause__ for the underlying reason","handlingStrategy":"try-catch","validationCode":"import requests\n\ndef github_api_ok(repo: str) -> bool:\n    try:\n        r = requests.get(\n            f\"https://api.github.com/repos/{repo}/releases/latest\", timeout=5\n        )\n        return r.status_code == 200\n    except requests.RequestException:\n        return False","typeGuard":null,"tryCatchPattern":"from g4f.version import get_github_version, VersionNotFoundError\n\ntry:\n    v = get_github_version(\"xtekky/gpt4free\")\nexcept VersionNotFoundError as e:\n    cause = e.__cause__  # requests.HTTPError / ConnectionError — real reason\n    v = None","preventionTips":["Authenticate GitHub API calls or check infrequently to avoid 403 rate limits","Catch VersionNotFoundError around every update check","Log e.__cause__ to distinguish rate-limit vs network vs parse failures"],"tags":["network","github-api","rate-limit","version-check"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}