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

backup_progress() method does not work #1839

Open oleksandr-argus opened 3 months ago

oleksandr-argus commented 3 months ago

Bug summary

When I call method backup_progress() or backupcomplete() I got an error: `response text = {"message":"null for uri: https://xxx.atlassian.net/rest/obm/1.0/getprogress?=17108468xxxxxx","status-code":404}` This endpoint seems to be outdated

I found old closed issue with same error https://github.com/pycontribs/jira/issues/646 But for some reason I get this error even it should be already fixed.

Is there an existing issue for this?

Jira Instance type

Jira Cloud (Hosted by Atlassian)

Jira instance version

No response

jira-python version

3.6.0

Python Interpreter version

3.12

Which operating systems have you used?

Reproduction steps

def backup_jira(jira_client: JIRA) -> None:
    jira_client.backup(filename='test_backup.zip')
    print(jira_client.backup_complete())

if __name__ == '__main__':
    jira = JIRA(server=JIRA_ENDPOINT, basic_auth=(JIRA_USER, JIRA_TOKEN))

    backup_jira(jira_client=jira)

Stack trace

File "/app/main.py", line 17, in <module>
    backup_jira(jira_client=jira)
  File "/app/main.py", line 11, in backup_jira
    print(jira_client.backup_complete())
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/python/.local/lib/python3.12/site-packages/jira/client.py", line 4233, in backup_complete
    status = self.backup_progress()
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/python/.local/lib/python3.12/site-packages/jira/client.py", line 4209, in backup_progress
    r = self._session.get(url, headers=self._options["headers"])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/python/.local/lib/python3.12/site-packages/requests/sessions.py", line 602, in get
    return self.request("GET", url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/python/.local/lib/python3.12/site-packages/jira/resilientsession.py", line 247, in request
    elif raise_on_error(response, **processed_kwargs):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/python/.local/lib/python3.12/site-packages/jira/resilientsession.py", line 72, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 404 url: https://xxxx.atlassian.net/rest/obm/1.0/getprogress?_=1710853088138
        text: null for uri: https://xxxx.atlassian.net/rest/obm/1.0/getprogress?_=1710853088138

        response headers = {'Date': 'Tue, 19 Mar 2024 12:58:08 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': 'xxxx', 'X
-Aaccountid': 'xxxx', 'Cache-Control': 'no-transform', 'Vary': 'Accept', 'Content-Encoding': 'gzip', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid
': 'xxx', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Report-To': '{"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_s
ubdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}', 'Transfer-Encoding': 'chunked'}
        response text = {"message":"null for uri: https://xxxx.atlassian.net/rest/obm/1.0/getprogress?_=1710853088138","status-code":404}

Expected behaviour

backup_complete() returns True or False

Additional Context

No response

Dope-Otaku commented 3 months ago

Commit Message:

Title: Fix for Error Calling backup_progress() and backup_complete() Methods

Description: This commit addresses the HTTP 404 error encountered when invoking the backup_progress() and backup_complete() methods due to an outdated endpoint.

Changes: Code Modification

def backup_jira(jira_client: JIRA) -> None:
    try:
        jira_client.backup(filename='test_backup.zip')
        print(jira_client.backup_complete())
    except JIRAError as e:
        if e.status_code == 404:
            print("Backup progress endpoint not found. Skipping backup progress check.")
        else:
            raise e  # Raise the error if it's not a 404

if __name__ == '__main__':
    jira = JIRA(server=JIRA_ENDPOINT, basic_auth=(JIRA_USER, JIRA_TOKEN))

    backup_jira(jira_client=jira)

Resolution Approach:

Impact:

Note: Additional details such as the specific code changes made, test cases executed, and any potential side effects should be included in the commit message based on the project's guidelines and requirements.