Joffreybvn commented on PR #31672:
URL: https://github.com/apache/airflow/pull/31672#issuecomment-1574215250
I just gave it a try, but that doesn't work: When `advanced_mode` is set to
True, a raw `requests.models.Response` get returned, which doesn't has any
`get` method:
```
Traceback (most recent call last):
File
"/opt/app-root/lib64/python3.9/site-packages/airflow/providers/atlassian/jira/operators/jira.py",
line 79, in execute
output = jira_result.get("id", None) if jira_result is not None else None
AttributeError: 'Response' object has no attribute 'get'
```
See the rest api methods like
[post](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/rest_client.py#L309),
get, put, ... of the
[AtlassianRestAPI](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/rest_client.py)
object: without advanced mode, we get a dict via the
[`_response_handler`](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/rest_client.py#L142)
method. With advanced mode, the raw `Response` object is returned. And many
methods in the Jira object (e.g.
[`issues_get_comments_by_id`](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/jira.py#L391))
will simply returns that `Response` object.
---
Looking further in the Jira client, they are some methods that just returns
something else than a dict:
- int
[`get_transition_id_to_status_name`](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/jira.py#L2742)
- iterable
[`project_leaders`](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/jira.py#L2623)
- list
[`get_all_screen_fields`](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/jira.py#L2958)
(haven't checked every method)
---
And actually, are [those lines
(79-80)](https://github.com/apache/airflow/blob/main/airflow/providers/atlassian/jira/operators/jira.py#L79-L80)
even needed ?
The test mock for the
[`jql_get_list_of_tickets`](https://github.com/apache/airflow/blob/main/tests/providers/atlassian/jira/operators/test_jira.py#L66-L70)
method returns a dict with an `id` key (see `minimal_test_ticket`). But this
method is supposed to [return a
list](https://github.com/atlassian-api/atlassian-python-api/blob/0497b617916274b8aa3677265540b0fd06196663/atlassian/jira.py#L3027).
The only valid test case is the one testing `issue_add_comment`, where there
is a ticket id returned.
-> I have the feeling that the 'id' key exist is very few cases.
<br>
I suggest to merge this PR, so that the JiraOperator is usable. I'll
continue to explore the Jira API, and will later create other PR with correct
tests case. And maybe at that point we can discuss a better xcom.push ? What do
you think ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]