atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.29k stars 644 forks source link

PDF-Export can fail with <100% which is not handled #1202

Closed MaZderMind closed 11 months ago

MaZderMind commented 11 months ago

The Code in get_pdf_download_url_for_confluence_cloud checks for errors in the PDF Export like this:

                if percentage_complete == 100:
                    running_task = False
                    log.info("Task completed - {task_state}".format(task_state=task_state))
                    if task_state == "FAILED":
                        log.error("PDF conversion not successful.")
                        return None
                    log.debug("Extract task results to download PDF.")
                    task_result_url = progress_response.get("result")
                else:
…

However, pages can fail at any percentage, leading to repeated checks (which never complete):

INFO:atlassian.confluence:50% - FAILED
INFO:atlassian.confluence:Check if export task has completed.
INFO:atlassian.confluence:50% - FAILED
INFO:atlassian.confluence:Check if export task has completed.
…

The Code should the Task-State at every poll-roundtrip and return an error whenever it is ERROR.