Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bot/code_review_bot/revisions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions bot/tests/test_revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down