pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.94k stars 859 forks source link

For issues returned from search_issues(), get_field() does not work for custom fields. #1697

Open vectro opened 1 year ago

vectro commented 1 year ago

Bug summary

When the display name of a custom field is passed into the fields parameter of search_issues(), the field name is correctly mapped to the internal Jira field name when placing the search request. However, afterwards the field values are only mapped back to the display name in the raw attribute of issues, which means that calling get_field() on one of the returned issues with the displayed field name will raise an AttributeError exception.

Is there an existing issue for this?

Jira Instance type

Jira Server or Data Center (Self-hosted)

Jira instance version

8.20.11

jira-python version

3.5.2

Python Interpreter version

3.9.6

Which operating systems have you used?

Reproduction steps

1. Given a Jira client instance

jira: JIRA

2. Call search_issues() with a custom field.

issues = jira.search_issues(jql=..., fields=['My custom field'])

3. Try to call get_field() on one of the returned issues.

my_custom_field_value = issues[0].get_field('My custom field')

Stack trace

[15] > jira/resources.py(701)get_field()
-> return getattr(self.fields, field_name)
AttributeError: 'PropertyHolder' object has no attribute 'My custom field'

Expected behaviour

Value of custom field would be returned.

Additional Context

No response