{"record":{"id":"d9aa7dbd5a71c097","repo":"crewAIInc/crewAI","slug":"unable-to-access-repository-repo-name-e","errorCode":null,"errorMessage":"Unable to access repository {repo_name}: {e}","messagePattern":"Unable to access repository (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/rag/loaders/github_loader.py","lineNumber":43,"sourceCode":"        gh_token = metadata.get(\"gh_token\")\n        content_types = metadata.get(\"content_types\", [\"code\", \"repo\"])\n\n        repo_url = source.source\n        if not repo_url.startswith(\"https://github.com/\"):\n            raise ValueError(f\"Invalid GitHub URL: {repo_url}\")\n\n        parts = repo_url.replace(\"https://github.com/\", \"\").strip(\"/\").split(\"/\")\n        if len(parts) < 2:\n            raise ValueError(f\"Invalid GitHub repository URL: {repo_url}\")\n\n        repo_name = f\"{parts[0]}/{parts[1]}\"\n\n        g = Github(gh_token) if gh_token else Github()\n\n        try:\n            repo = g.get_repo(repo_name)\n        except GithubException as e:\n            raise ValueError(f\"Unable to access repository {repo_name}: {e}\") from e\n\n        all_content = []\n\n        if \"repo\" in content_types:\n            all_content.append(f\"Repository: {repo.full_name}\")\n            all_content.append(f\"Description: {repo.description or 'No description'}\")\n            all_content.append(f\"Language: {repo.language or 'Not specified'}\")\n            all_content.append(f\"Stars: {repo.stargazers_count}\")\n            all_content.append(f\"Forks: {repo.forks_count}\")\n            all_content.append(\"\")\n\n        if \"code\" in content_types:\n            try:\n                readme = repo.get_readme()\n                all_content.append(\"README:\")\n                all_content.append(readme.decoded_content.decode(errors=\"ignore\"))\n                all_content.append(\"\")\n            except GithubException:","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/rag/loaders/github_loader.py#L25-L61","documentation":"Raised by GithubLoader.load() when g.get_repo(repo_name) throws GithubException — the PyGithub call to the GitHub API failed. Common causes: repository does not exist (404), the repo is private and no/insufficient token was supplied (401/403), or the token lacks scopes. The original exception is chained so the HTTP status is visible in the message.","triggerScenarios":"Loading a private repo without passing metadata={'gh_token': ...}; using a revoked or expired personal access token; naming a repo that was renamed or deleted; hitting GitHub rate limits (403) because requests are made anonymously and the unauthenticated quota (60/hour/IP) is exhausted.","commonSituations":"Forgetting that unauthenticated GitHub API access is rate-limited to 60 requests/hour; fine-grained PATs missing the repo's read permission; org repos with SSO the token has not been authorized for; CI environments where GITHUB_TOKEN was not forwarded into metadata.","solutions":["Pass a token: GithubLoader().load(src, metadata={'gh_token': os.environ['GITHUB_TOKEN']}) — this raises the rate limit to 5000/hour and unlocks private repos you can access.","Verify the repo exists and the spelling/case is right by opening https://github.com/owner/repo or calling the API with curl.","For fine-grained PATs, grant the repository read access; for classic tokens ensure 'repo' scope for private repos.","Handle rate limiting with backoff or by caching results between runs."],"exampleFix":"# before\nresult = GithubLoader().load(SourceContent('https://github.com/acme/private-repo'))  # 404\n\n# after\nimport os\nresult = GithubLoader().load(\n    SourceContent('https://github.com/acme/private-repo'),\n    metadata={'gh_token': os.environ['GITHUB_TOKEN']},\n)","handlingStrategy":"try-catch","validationCode":"import os\\n\\ndef github_token() -> str | None:\\n    tok = os.environ.get('GITHUB_TOKEN')\\n    if not tok:\\n        raise RuntimeError('GITHUB_TOKEN not set; private repos and high rate limits need it')\\n    return tok","typeGuard":null,"tryCatchPattern":"try:\\n    result = GithubLoader().load(source, metadata={'gh_token': tok})\\nexcept ValueError as e:\\n    if 'Unable to access repository' in str(e):\\n        if is_rate_limited():\\n            sleep_and_retry_later()\\n        else:\\n            raise RuntimeError('check repo name and token scopes') from e\\n    raise","preventionTips":["Always pass a token via metadata for production ingestion.","Check token scopes (repo read) for private repositories.","Cache repo content; 60 req/h anonymous quota exhausts in one large load."],"tags":["github","authentication","rate-limit","network"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}