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.95k stars 869 forks source link

Dont replace jira url #1913

Open dimanoga opened 1 day ago

dimanoga commented 1 day ago

Bug summary

Hi there,

In our company, API access is provided through a white list system. To "fix" IP addresses, we use Nginx as a proxy server for accessing Jira. However, we have noticed that when we use the connection.issuel), in the dictresource method, the URL is replaced with one that Jira returns, rather than the one from which the request originated. Additionally, when updating issues using the issue.update method, the URL used is not the one that the authorization was initiated from, but rather the one provided by the Jira server.

Due to this, when attempting to update a task, we receive a 401 unauthorized error. We are hoping to resolve this issue and ensure that the correct URL is used for all API requests.

Could you please assist us in resolving this issue? We would greatly appreciate any assistance you can provide. Thank you in advance for your attention.

Is there an existing issue for this?

Jira Instance type

Jira Server or Data Center (Self-hosted)

Jira instance version

8.20.0

jira-python version

3.5.2

Python Interpreter version

3.11

Which operating systems have you used?

Reproduction steps

#1 connect to jira via nginx url
connection = JIRA(options={'server':"https://my-nginx.url/', 'verify': False}, auth=(login, pass))
#2 get issue
issue = connection.issue(key='JIRA-1')
#3 try to update issue
issue.update(fields={'description':'test'}) # the url is already used here = jira.company.com

Stack trace

File "/PycharmProjects/portal_back/venv/lib/python3.11/site-packages/jira/resources•py", Line 852, in update
super (). update(async_=async_, jira-jira, notify=notify, fields=data)
File "/PycharmProjects/portal_back/venv/lib/python3.11/site-packages/jira/resources-py", Line 328, in update
r = self._session.put (self.self + querystring, data-json.dumps (data))
Fetur se. euest Por, urt, vtadta, uergs) se-packages/requests/sesstons.py". Line 649, in put.
File "/PycharmProjects/portal_back/venv/lib/python3.11/site-packages/jira/resilientsession-py", line 247, in request elif raise_on_error (response, **processed_kwargs):
File "/PycharmProjects/portal_back/venv/lib/python3.11/site-packages/jira/resilientsession-py", Line 72, in raise_on_error
raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 401 url: https://jira.company.com/rest/api/2/issue/15832118
text: You do not have the permission to see the specified issue., Login Required
response headers = {''}
response text = ("errorMessages": ["You do not have the permission to see the specified issue.", "Login Required"], "errors":}}
Process finished with exit code 1

Expected behaviour

The Jira URL has not been replaced, but the one that was used for authorization is still being used,

Additional Context

No response

ichimukuren commented 1 day ago

We’re experiencing a very similar issue in our setup! We also use Nginx as a proxy for Jira with IP whitelisting, and have noticed the URL handling seems inconsistent, which causes authentication errors like the 401 Unauthorized you mentioned.

It would be great if the Jira team could help clarify or address this behavior. Thanks for sharing your experience—it’s helpful to know we’re not alone with this issue!