Skip to content

Commit e5aee7c

Browse files
authored
Resolve 'TypeError' in _setup_split_targets_build() (#5047)
This change addresses a `TypeError` in `_setup_split_targets_build()`. [The error](https://pantheon.corp.google.com/errors/detail/CNbfppvCxoWiyAE;locations=global?project=google.com:cluster-fuzz) arises when `_get_targets_list()` returns `None`, because there is an attempt to check for `fuzz_target` in a `NoneType` object. To fix this, a separate check has been introduced to verify that `targets_list` is not `None` before it is iterated over.
1 parent 45eecc6 commit e5aee7c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/clusterfuzz/_internal/build_management/build_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ def _setup_split_targets_build(bucket_path, fuzz_target, revision=None):
11511151

11521152
# Check this so that we handle deleted targets properly.
11531153
targets_list = _get_targets_list(bucket_path)
1154-
if fuzz_target not in targets_list:
1154+
if not targets_list or fuzz_target not in targets_list:
11551155
raise errors.BuildNotFoundError(revision, environment.get_value('JOB_NAME'))
11561156

11571157
fuzz_target_bucket_path = _full_fuzz_target_path(bucket_path, fuzz_target)

src/clusterfuzz/_internal/tests/core/build_management/build_manager_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,6 +1731,12 @@ def test_target_not_built(self):
17311731
os.environ['FUZZ_TARGET_BUILD_BUCKET_PATH'])
17321732
self.assertCountEqual(['target1', 'target3'], targets_list)
17331733

1734+
def test_setup_split_build_no_targets_list(self):
1735+
"""Test that BuildNotFoundError is raised when the targets list is missing."""
1736+
self.mock.read_data.return_value = None
1737+
with self.assertRaises(errors.BuildNotFoundError):
1738+
build_manager.setup_build(fuzz_target='target3')
1739+
17341740
def test_target_no_longer_built(self):
17351741
"""Test a target that's not longer listed in target.list."""
17361742
test_helpers.patch(self, [

0 commit comments

Comments
 (0)