44
55from codeflash .api .cfapi import is_github_app_installed_on_repo
66from 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
88from codeflash .code_utils .compat import LF
99from 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
2020def 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