Skip to content

Conversation

@floatingstatic
Copy link
Collaborator

  • There are some cases where labels may not be an attribute of if an issue as one st2 user pointed out in Jira pack : Python error AttributeError: 'PropertyHolder' object has no attribute 'labels' #53 . Two actions, add_field_value and update_field_value returned issue.fields.labels (list) regardless of which field was being updated which seems a bit counter-intuitive to someone updating something like the description or summary fields of an issue. We now return a dictionary representation of an issue when running these actions as we do in other actions such as create_issue for consistency. The dictionary that is returned includes labels if they exist. This may be a breaking change for any users that are expecting the result from these two actions to be a list of labels instead of a dictionary that includes labels as a key.

  • The update_field_value action is unable to update the labels field because the JIRA API expects these to be posted as a list instead of a string. This is discussed in Add support for general api token #54 . We modify the action code to split the value parameter of update_field_value so it becomes a list only in the case where field is equal to "labels". Example invocation to illustrate how this works:

st2 action execute jira.update_field_value issue_key=NETOPS-1 field=labels value='Label1 Label2'

This updates the issue being modified so its labels field becomes:

labels:
    - Label1
    - Label2

@floatingstatic floatingstatic requested a review from a team as a code owner August 11, 2023 21:09
@floatingstatic floatingstatic requested review from amanda11 and removed request for a team August 11, 2023 21:09
@CLAassistant
Copy link

CLAassistant commented Aug 11, 2023

CLA assistant check
All committers have signed the CLA.

@floatingstatic
Copy link
Collaborator Author

@armab Tagging you as I'd like an opinion on changing the return type for add_field_value and update_field_value. I suspect most users are not checking the response object when running this action given it was always the labels field of an issue.

Fix update_field_value when field is 'labels'

Signed-off-by: Jeremiah Millay <[email protected]>
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

I don't use JIRA pack, but the explanation behind this improvement makes a lot of sense 👍
Thanks for the PR!

Comment on lines +5 to +13
- `add_field_value` and `update_field_value` actions now return a dictionary representation of the issue being modified. Previously these actions would return
only the `labels` field if it exists as an attribute. This addresses [#53](https://github.com/StackStorm-Exchange/stackstorm-jira/issues/53) but is also beneficial for displaying other field values (inclusive of `labels`) that may have been updated.

- Fix for [#54](https://github.com/StackStorm-Exchange/stackstorm-jira/issues/54) which prevents callers of the `update_field_value` action from updating `labels` which must be passed as a list via the api. As labels cannot contain spaces we split
the `value` field of this action on whitespace in the case where `field` == `"labels"`. Example invocation:

```
st2 action execute jira.update_field_value issue_key=NETOPS-1 field=labels value='Label1 Label2'
```
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the detailed explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants