Skip to content

Commit 13f39c0

Browse files
committed
enhance the GitHub App is not installed error message
1 parent 10aacfd commit 13f39c0

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

codeflash/code_utils/github_utils.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from codeflash.api.cfapi import is_github_app_installed_on_repo
66
from codeflash.cli_cmds.cli_common import apologize_and_exit
7-
from codeflash.cli_cmds.console import logger
7+
from codeflash.cli_cmds.console import logger, paneled_text
88
from codeflash.code_utils.compat import LF
99
from codeflash.code_utils.git_utils import get_repo_owner_and_name
1010

@@ -18,15 +18,20 @@ def get_github_secrets_page_url(repo: Optional[Repo] = None) -> str:
1818

1919

2020
def require_github_app_or_exit(owner: str, repo: str) -> None:
21-
if not is_github_app_installed_on_repo(owner, repo):
22-
logger.error(
23-
f"It looks like the Codeflash GitHub App is not installed on the repository {owner}/{repo} or the GitHub"
24-
f" account linked to your CODEFLASH_API_KEY does not have access to the repository {owner}/{repo}.{LF}"
25-
"Before continuing, please install the Codeflash GitHub App on your repository by visiting "
26-
f"https://github.com/apps/codeflash-ai/installations/select_target{LF}"
21+
# Suppress low-level HTTP error logging to avoid duplicate logs; we present a friendly panel instead
22+
if not is_github_app_installed_on_repo(owner, repo, suppress_errors=True):
23+
# Show a clear, user-friendly panel instead of raw error logs
24+
message = (
25+
f"It looks like the Codeflash GitHub App is not installed on the repository {owner}/{repo} "
26+
f"or the GitHub account linked to your CODEFLASH_API_KEY does not have access to the repository {owner}/{repo}.{LF}{LF}"
27+
"To continue, install the Codeflash GitHub App on your repository:"\
28+
f"{LF}https://github.com/apps/codeflash-ai/installations/select_target{LF}{LF}"
29+
"Tip: If you want to find optimizations without opening PRs, run Codeflash with the --no-pr flag."
2730
)
28-
logger.error(
29-
f"Note: if you want to find optimizations without opening PRs, you can run Codeflash with the --no-pr flag.{LF}"
31+
paneled_text(
32+
message,
33+
panel_args={"title": "GitHub App Required", "border_style": "red", "expand": False},
34+
text_args={"style": "bold red"},
3035
)
3136
apologize_and_exit()
3237

0 commit comments

Comments
 (0)