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.91k stars 856 forks source link

Unnecessary api call to /rest/api/2/field #1859

Open aneeshco opened 2 months ago

aneeshco commented 2 months ago

Bug summary

When doing api call using search_issues, it makes two API calls, one GET to the endpoint /rest/api/2/field and another to the actual url /rest/api/2/search. The first api call, returns the whole fields present in the JIRA server environment causing performance issues in the server. This is only done once the first time the function is used. Can this function be updated so that only the /rest/api/2/search is accessed?

issues_page = jira.search_issues( jql_query, startAt=start_at, maxResults=MAX_RESULTS, validate_query=False, fields=fields_arg, expand=None, properties=None, use_post=True)

Is there an existing issue for this?

Jira Instance type

Jira Server or Data Center (Self-hosted)

Jira instance version

9.4.6

jira-python version

3.8

Python Interpreter version

3.11.5

Which operating systems have you used?

Reproduction steps

# 1. Given a Jira client instance
jira: JIRA
# 2. When I call the function with below arguments 
issues_page = jira.search_issues(
                jql_query, 
                startAt=start_at, 
                maxResults=MAX_RESULTS,
                validate_query=False,
                fields=fields_arg,
                expand=None,
                properties=None,
                use_post=True)
# 3. It first calls the field endpoint and then it calls the search endpoint the first time, subsequent times doesnot include calls to field endpoint
# 4. It should only call the search endpoint and not the field endpoint
...

Stack trace

The order of api calls as below when

/rest/api/2/serverInfo - authentication
/rest/api/2/field -  first call to search_issues function
/rest/api/2/search - first call to search_issues function
/rest/api/2/search - second call to search_issues function
/rest/api/2/search - third call to search_issues function
/rest/api/2/search - fourth call to search_issues function

Expected behaviour

Expected behaviour as below /rest/api/2/serverInfo - authentication /rest/api/2/search - first call to search_issues function /rest/api/2/search - second call to search_issues function /rest/api/2/search - third call to search_issues function /rest/api/2/search - fourth call to search_issues function

Additional Context

None