From 9acd52497994552f835fe7620b087deecf77a3e2 Mon Sep 17 00:00:00 2001 From: richarddushime Date: Wed, 5 Feb 2025 10:54:53 +0100 Subject: [PATCH] GitHub Action Fails Due to Unsupported Encoding in check_images_in_pr.py --- scripts/webp_conversion/check_images_in_pr.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/webp_conversion/check_images_in_pr.py b/scripts/webp_conversion/check_images_in_pr.py index 4a163cbdc1..071ca2e00c 100644 --- a/scripts/webp_conversion/check_images_in_pr.py +++ b/scripts/webp_conversion/check_images_in_pr.py @@ -62,9 +62,12 @@ def is_url(image_ref): # Check for references in text files elif filename.lower().endswith(TEXT_EXTENSIONS) and status in ('added', 'modified'): try: - # Fetch the file content from the PR's head SHA contents = repo.get_contents(filename, ref=pr.head.sha) - file_content = contents.decoded_content.decode('utf-8', errors='ignore') + if contents.encoding == "base64": + file_content = contents.decoded_content.decode('utf-8', errors='ignore') + else: + print(f"Warning: Unsupported encoding '{contents.encoding}' for {filename}. Skipping.", file=sys.stderr) + continue except GithubException as e: print(f"Warning: Could not fetch content for {filename}. Skipping. Error: {e}", file=sys.stderr) continue