From e3abe1224312b6acdab735f01a402d0cc7ce8a2d Mon Sep 17 00:00:00 2001 From: Mohammad Mohtashim <45242107+keenborder786@users.noreply.github.com> Date: Tue, 19 Dec 2023 21:08:06 +0500 Subject: [PATCH] community[patch]: helpful error message for GitHubAPIWrapper (#14803) Very simple change in relation to the issue https://github.com/langchain-ai/langchain/issues/14550 @baskaryan, @eyurtsev, @hwchase17. --------- Co-authored-by: Harrison Chase Co-authored-by: Bagatur --- .../langchain_community/utilities/github.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/utilities/github.py b/libs/community/langchain_community/utilities/github.py index d6e1a0833e..e9929e451f 100644 --- a/libs/community/langchain_community/utilities/github.py +++ b/libs/community/langchain_community/utilities/github.py @@ -76,8 +76,16 @@ class GitHubAPIWrapper(BaseModel): private_key, ) gi = GithubIntegration(auth=auth) - installation = gi.get_installations()[0] - + installation = gi.get_installations() + if not installation: + raise ValueError( + f"Please make sure to install the created github app with id " + f"{github_app_id} on the repo: {github_repository}" + "More instructions can be found at " + "https://docs.github.com/en/apps/using-" + "github-apps/installing-your-own-github-app" + ) + installation = installation[0] # create a GitHub instance: g = installation.get_github_for_installation() repo = g.get_repo(github_repository)