diff --git a/config.py b/config.py index 530b38ff..080c35a7 100644 --- a/config.py +++ b/config.py @@ -52,7 +52,7 @@ def get_env_var(name: str) -> str: OPENAI_FINAL_STATUSES = ["cancelled", "completed", "expired", "failed"] OPENAI_MAX_ARRAY_LENGTH = 32 # https://community.openai.com/t/assistant-threads-create-400-messages-array-too-long/754574/1 OPENAI_MAX_STRING_LENGTH = 256000 # https://community.openai.com/t/assistant-threads-create-400-messages-array-too-long/754574/5 -OPENAI_MAX_CONTEXT_TOKENS = 128000 # https://gitauto-ai.sentry.io/issues/5582421515/events/9a09416e714c4a66bf1bd86916702be2/?project=4506865231200256&referrer=issue_details.related_trace_issue +OPENAI_MAX_CONTEXT_TOKENS = 120000 # Secured 8,000 as a buffer. https://gitauto-ai.sentry.io/issues/5582421515/events/9a09416e714c4a66bf1bd86916702be2/?project=4506865231200256&referrer=issue_details.related_trace_issue OPENAI_MAX_RETRIES = 3 OPENAI_MAX_TOOL_OUTPUTS_SIZE = 512 * 1024 # in bytes OPENAI_MAX_TOKENS = 4096 diff --git a/services/check_run_handler.py b/services/check_run_handler.py index 87c87389..1681bcf3 100644 --- a/services/check_run_handler.py +++ b/services/check_run_handler.py @@ -1,6 +1,7 @@ # Local imports import json from config import ( + EMAIL_LINK, GITHUB_APP_USER_NAME, STRIPE_PRODUCT_ID_FREE, SUPABASE_URL, @@ -155,11 +156,20 @@ def handle_check_run(payload: CheckRunCompletedPayload) -> None: # Get the error log from the workflow run comment_body = "Checking out the error log from the workflow run..." update_comment(body=comment_body, base_args=base_args, p=20) - error_log: str | None = get_workflow_run_logs( + error_log: str | int | None = get_workflow_run_logs( owner=owner_name, repo=repo_name, run_id=workflow_run_id, token=token ) + if error_log == 404: + permission_url = ( + f"https://github.com/organizations/{owner_name}/settings/installations/{installation_id}/permissions/update" + if owner_type == "Organization" + else f"https://github.com/settings/installations/{installation_id}/permissions/update" + ) + comment_body = f"Approve permission(s) to allow GitAuto to access the check run logs here: {permission_url}" + return update_comment(body=comment_body, base_args=base_args) if error_log is None: - return + comment_body = f"I couldn't find the error log. Contact {EMAIL_LINK} if the issue persists." + return update_comment(body=comment_body, base_args=base_args) # Plan how to fix the error comment_body = "Planning how to fix the error..." diff --git a/services/github/actions_manager.py b/services/github/actions_manager.py index 6c4cd135..39af2383 100644 --- a/services/github/actions_manager.py +++ b/services/github/actions_manager.py @@ -45,6 +45,8 @@ def get_workflow_run_logs(owner: str, repo: str, run_id: int, token: str): url = f"{GITHUB_API_URL}/repos/{owner}/{repo}/actions/runs/{run_id}/logs" headers = create_headers(media_type="", token=token) response = requests.get(url=url, headers=headers, timeout=TIMEOUT) + if response.status_code == 404 and "Not Found" in response.text: + return response.status_code response.raise_for_status() # Get the failed step file name