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

search_issue does not return the comments field. #1240

Closed
2 of 4 tasks
michaelpulis opened this issue Nov 15, 2021 · 2 comments · Fixed by #1360
Closed
2 of 4 tasks

search_issue does not return the comments field. #1240

michaelpulis opened this issue Nov 15, 2021 · 2 comments · Fixed by #1360
Labels
docs feature good first issue New contributors welcome !

Comments

@michaelpulis
Copy link

michaelpulis commented Nov 15, 2021

Bug summary

I am aware that a similar question has been asked before, however the response was to use the following:
jira.search_issues(jql, fields="comment, the other fields" ... )

I would like to retrieve ALL the fields + the comments. At runtime, my script does not know all the fields, so I cannot use the aforementioned workaround.

A workaround that I have considered is to send a small query with maxResults:1 and without the fields="comment" parameter to the search_issues(...) function. This will allow me to obtain all of the keys of the values within the fields parameter. I could then join them into a single string, and append ",comment" to it, and make my future requests with this new string as the fields parameter as such:

all_fields = ",".join(field_names) + ",comment"
jira.search_issues(jql, fields=all_fields)

However, this feels like a workaround. Would it be possible to add some parameter includeComments=True within the search_issues function to do this automatically?

Is there an existing issue for this?

  • I have searched the existing issues

Jira Instance type

Jira Server or Data Center (Self-hosted)

Jira instance version

8.14.0

jira-python version

main

Python Interpreter version

3.8

Which operating systems have you used?

  • Linux
  • macOS
  • Windows

Reproduction steps

# 1. Call search_issues(...) without specifying fields paramter
# 2. Observe that the result does not include the comments field
# 3. That's the issue

Stack trace

none really

Expected behaviour

Comments to be included, since the documentation says that omitting the fields parameter will return all the available fields.

Additional Context

No response

@adehad adehad added the feature label Nov 15, 2021
@adehad
Copy link
Contributor

adehad commented Nov 15, 2021

excellent report, thanks.

For getting all the fields I think you should also be able to use:

jira/jira/client.py

Lines 1138 to 1142 in 5ab6c29

def fields(self) -> List[Dict[str, Any]]:
"""Return a list of all issue fields.
Returns:
List[Dict[str, Any]]
.

But I agree, needing to get all the fields isn't really ideal.

@adehad adehad added the good first issue New contributors welcome ! label Nov 15, 2021
@michaelpulis
Copy link
Author

I have since found what I believe to be the correct way to do it.

If you use the following: jira.search_issues(jql, fields="*all,comments"), you will get all the fields and the comments too. I found this on the following page:
https://docs.atlassian.com/software/jira/docs/api/REST/8.13.13/#search-search

The link above is the documentation of the rest API, not the Python Jira Module, however it gives the desired result, as it returns all the fields and the comments too. So perhaps what was actually required is an update to the Jira Python module documentation (https://jira.readthedocs.io/api.html?highlight=search_issues#jira.client.JIRA.search_issues) to mention this functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs feature good first issue New contributors welcome !
Projects
None yet
2 participants