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

Certain endpoints like resolution are returning 406 due to invalid accept headers #1775

Open
2 of 4 tasks
ksallee opened this issue Dec 11, 2023 · 4 comments
Open
2 of 4 tasks

Comments

@ksallee
Copy link

ksallee commented Dec 11, 2023

Bug summary

Accept headers defined here: https://github.com/pycontribs/jira/blob/7846ac35a7e219dd3c1cd616a120a920f112b85e/jira/resilientsession.py#L145C9-L146C70
Seem to be invalid, because it should not be *.* but */*. I'm not sure if the bitbucket bug is still valid, can't open it.
As for the other one, it seems changing accept headers to "application/json;q=1.0, */*;q=0.9" won't break anything.

Is there an existing issue for this?

  • I have searched the existing issues

Jira Instance type

Jira Cloud (Hosted by Atlassian)

Jira instance version

No response

jira-python version

main

Python Interpreter version

3.11.1

Which operating systems have you used?

  • Linux
  • macOS
  • Windows

Reproduction steps

import jira

# This one fails with 406
jira = jira.JIRA(
    "https://some.jira.url",
    basic_auth=("user", "pass"),
)
resolutions = jira.resolutions()
print(resolutions)

# This one works
jira = jira.JIRA(
    "https://some.jira.url",
    basic_auth=("user", "pass"),
    options={
        "headers": {
            "Accept": "application/json;q=1.0, */*;q=0.9"
        }
    }
)
resolutions = jira.resolutions()
print(resolutions)


### Stack trace

```python
Traceback (most recent call last):
  File "/Users/kevin/dev/gpl/sg-jira/test_jira.py", line 37, in <module>
    resolutions = jira.resolutions()
                  ^^^^^^^^^^^^^^^^^^
  File "/Users/kevin/.pyenv/versions/googoo/lib/python3.11/site-packages/jira/client.py", line 2946, in resolutions
    r_json = self._get_json("resolution")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kevin/.pyenv/versions/googoo/lib/python3.11/site-packages/jira/client.py", line 3765, in _get_json
    r = self._session.get(url, params=params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kevin/.pyenv/versions/googoo/lib/python3.11/site-packages/requests/sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kevin/.pyenv/versions/googoo/lib/python3.11/site-packages/jira/resilientsession.py", line 223, in request
    elif raise_on_error(response, **processed_kwargs):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/kevin/.pyenv/versions/googoo/lib/python3.11/site-packages/jira/resilientsession.py", line 69, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 406 url: https://sgjiratechtrial.atlassian.net/rest/api/2/resolution

Expected behaviour

200 response

Additional Context

No response

@jabadia
Copy link

jabadia commented Dec 12, 2023

same as #1774

@dbaxa
Copy link
Member

dbaxa commented Dec 19, 2023

You should be able to workaround the issue by creating JIRA client instances like so ->

JIRA(url_to_jira_instance, basic_auth=("example", "apikeyhere"), 
     options={"headers": {"Accept": "application/json,*/*;q=0.9"}}) 

@ksallee
Copy link
Author

ksallee commented Dec 19, 2023

This is exactly what I did, but it required updating a bunch of apps and frameworks that define the JIRA URL, and since *.* doesn't even seem to be a valid MIME type, shouldn't it be fixed?

@thingscouldbeworse
Copy link

It looks like Atlassian made the same change in the server info endpoint last night causing the same 406's on just creating a client at all. Would be really nice to have the header fix merged in

AlexanderMakarov added a commit to AlexanderMakarov/activitywatch-ets that referenced this issue Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants