Skip to content

Commit 7c8f541

Browse files
Resolve AttributeError in issue_filer.py (#5154)
Safeguard the process of issue filing by ensuring the presence of attributes within `Issue` variants before accessing them. This issue occurs due to the changes made in #5074. #5074 adds debugging logs, and one of the logs tries to access an attribute (`component_id`) of a class (`Issue`), resulting in the following error: **'Issue' object has no attribute 'component_id'** This issue has blocked the issue filing process. The current changes aim to resolve this issue using `getattr()`, which checks if an attribute exists and only then accesses it.
1 parent c31c50c commit 7c8f541

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/clusterfuzz/_internal/issue_management/issue_filer.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ def file_issue(testcase,
327327

328328
issue = issue_tracker.new_issue()
329329
if issue_tracker.project == 'google-buganizer':
330-
logs.info(f"New issue's default component id = {issue.component_id}")
330+
default_component_id = getattr(issue, 'component_id', None)
331+
logs.info(f"New issue's default component id = {default_component_id}")
331332
issue.title = data_handler.get_issue_summary(testcase)
332333
issue.body = data_handler.get_issue_description(
333334
testcase, reporter=user_email, show_reporter=True)
@@ -492,8 +493,10 @@ def file_issue(testcase,
492493
if issue_tracker.project == 'google-buganizer':
493494
logs.info('The values of Component IDs:')
494495
logs.info(f'1. Backing: {list(issue.components)}')
495-
logs.info(f'2. Removed: {list(issue.components.removed)}')
496-
logs.info(f'3. Added: {list(issue.components.added)}')
496+
removed = list(getattr(issue.components, 'removed', []))
497+
logs.info(f'2. Removed: {removed}')
498+
added = list(getattr(issue.components, 'added', []))
499+
logs.info(f'3. Added: {added}')
497500
logs.info('Primary attempt to the save the issue.')
498501
issue.save()
499502
except Exception as e:

0 commit comments

Comments
 (0)