Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set component id if a numeric component is available in the component… #4008

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,14 @@ def save(self, new_comment=None, notify=True):
# Make sure self.labels contains only hotlist IDs.
self._filter_labels()

if self.component_id:
self._data['issueState']['componentId'] = int(self.component_id)
# Best effort setting on componentId from list of components.
# Set the componentId to the first encountered numeric component
# in the component list.
for component in list(self.components):
if component.isnumeric():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm...will component ever be an int? this will fail in that case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not be an int, we are doing the same thing a few lines above:

component_paths = self._get_component_paths(self.components)

self._data['issueState']['componentId'] = int(component)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this it will set the first component that predator returns. It would be worth looking in logs for components in predator responses to see what is being returned. Maybe the first is not what we want, but it is likely impossible to say what we want.
Perhaps a better way to handle this is to say iff the size of self.components is 1 then set the componentId, otherwise leave it alone.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though as mentioned in b/341800538#comment8 the PEEPs bot is probably setting things to the 1st component anyway (would be good to verify what actually happens).

break

ccs = list(self._ccs)
if ccs:
self._data['issueState']['ccs'] = _make_users(ccs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def test_new_issue_with_component_tags(self):
body={
'issueState': {
'componentId':
1337,
1456567,
'ccs': [{
'emailAddress': '[email protected]'
}],
Expand Down
Loading