From 652f58c734f72359054fcf7f3775b21c1b7217e4 Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 21 Jun 2024 18:07:46 +0800 Subject: [PATCH 1/3] fix: remove token check for report --- codecov_cli/services/report/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codecov_cli/services/report/__init__.py b/codecov_cli/services/report/__init__.py index 21b81ca4..81e23f25 100644 --- a/codecov_cli/services/report/__init__.py +++ b/codecov_cli/services/report/__init__.py @@ -8,7 +8,7 @@ from codecov_cli.helpers.config import CODECOV_API_URL from codecov_cli.helpers.encoder import decode_slug, encode_slug from codecov_cli.helpers.request import ( - get_token_header_or_fail, + get_token_header, log_warnings_and_errors_if_any, request_result, send_post_request, @@ -46,7 +46,7 @@ def send_create_report_request( commit_sha, code, service, token, encoded_slug, enterprise_url, pull_request_number ): data = {"code": code} - headers = get_token_header_or_fail(token) + headers = get_token_header(token) upload_url = enterprise_url or CODECOV_API_URL url = f"{upload_url}/upload/{service}/{encoded_slug}/commits/{commit_sha}/reports" return send_post_request(url=url, headers=headers, data=data) From a40e072b4fd31a0cc65403611ce1c29e0dc8d4db Mon Sep 17 00:00:00 2001 From: Tom Hu Date: Fri, 21 Jun 2024 20:57:50 +0800 Subject: [PATCH 2/3] fix: use the entire blip --- codecov_cli/services/report/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/codecov_cli/services/report/__init__.py b/codecov_cli/services/report/__init__.py index 81e23f25..af8a1237 100644 --- a/codecov_cli/services/report/__init__.py +++ b/codecov_cli/services/report/__init__.py @@ -80,7 +80,13 @@ def create_report_results_logic( def send_reports_result_request( commit_sha, report_code, encoded_slug, service, token, enterprise_url ): - headers = get_token_header_or_fail(token) + tokenless = os.environ.get("TOKENLESS") + if tokenless: + headers = None # type: ignore + branch = tokenless # type: ignore + logger.info("The PR is happening in a forked repo. Using tokenless upload.") + else: + headers = get_token_header_or_fail(token) upload_url = enterprise_url or CODECOV_API_URL url = f"{upload_url}/upload/{service}/{encoded_slug}/commits/{commit_sha}/reports/{report_code}/results" return send_post_request(url=url, headers=headers) From 95d25d4c72101971fc468d2db76a5d5eaf264f94 Mon Sep 17 00:00:00 2001 From: joseph-sentry Date: Fri, 21 Jun 2024 10:29:46 -0400 Subject: [PATCH 3/3] fix: don't try tokenless in create report results Signed-off-by: joseph-sentry --- codecov_cli/services/report/__init__.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/codecov_cli/services/report/__init__.py b/codecov_cli/services/report/__init__.py index af8a1237..b8e7c445 100644 --- a/codecov_cli/services/report/__init__.py +++ b/codecov_cli/services/report/__init__.py @@ -9,6 +9,7 @@ from codecov_cli.helpers.encoder import decode_slug, encode_slug from codecov_cli.helpers.request import ( get_token_header, + get_token_header_or_fail, log_warnings_and_errors_if_any, request_result, send_post_request, @@ -80,13 +81,7 @@ def create_report_results_logic( def send_reports_result_request( commit_sha, report_code, encoded_slug, service, token, enterprise_url ): - tokenless = os.environ.get("TOKENLESS") - if tokenless: - headers = None # type: ignore - branch = tokenless # type: ignore - logger.info("The PR is happening in a forked repo. Using tokenless upload.") - else: - headers = get_token_header_or_fail(token) + headers = get_token_header_or_fail(token) upload_url = enterprise_url or CODECOV_API_URL url = f"{upload_url}/upload/{service}/{encoded_slug}/commits/{commit_sha}/reports/{report_code}/results" return send_post_request(url=url, headers=headers)