From 8db2363edbb956f44d4276b2f4af30cf29ec3140 Mon Sep 17 00:00:00 2001 From: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com> Date: Thu, 23 Jul 2026 03:46:16 -0700 Subject: [PATCH] fix: ignore binary issue files Skip files that cannot be decoded while building issue hashes so binary artifacts cannot abort publication. Add a regression for the reported WebP failure. --- bot/code_review_bot/revisions/base.py | 4 ++-- bot/tests/test_revisions.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bot/code_review_bot/revisions/base.py b/bot/code_review_bot/revisions/base.py index 4b2d42bad..991b238a4 100644 --- a/bot/code_review_bot/revisions/base.py +++ b/bot/code_review_bot/revisions/base.py @@ -174,8 +174,8 @@ def get_file_content( try: with (local_cache_repository / file_path).open() as f: file_content = f.read() - except (FileNotFoundError, IsADirectoryError): - logger.warning("Failed to find issue's related file", path=file_path) + except (FileNotFoundError, IsADirectoryError, UnicodeDecodeError): + logger.warning("Failed to read issue's related file", path=file_path) file_content = None else: try: diff --git a/bot/tests/test_revisions.py b/bot/tests/test_revisions.py index 03afc2b07..43e37cc05 100644 --- a/bot/tests/test_revisions.py +++ b/bot/tests/test_revisions.py @@ -93,6 +93,13 @@ def test_autoland(mock_config, mock_revision_autoland): ) +def test_binary_file_content_is_ignored(mock_revision, tmp_path): + binary_file = tmp_path / "artifact.webp" + binary_file.write_bytes(b"RIFF\xac=\x00\x00WEBP") + + assert mock_revision.get_file_content(binary_file.name, tmp_path) is None + + def test_clang_files(mock_revision): """ Test clang files detection