atlassian-api / atlassian-python-api

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

confluence: correctly report a failed pdf-export #1203

Closed MaZderMind closed 1 year ago

MaZderMind commented 1 year 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.
…

This change makes the code check the Task-State at every poll-roundtrip and return an error whenever it is ERROR. fixes #1202

codecov-commenter commented 1 year ago

Codecov Report

Patch and project coverage have no change.

Comparison is base (5d9cd15) 34.84% compared to head (96f82b5) 34.84%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1203 +/- ## ======================================= Coverage 34.84% 34.84% ======================================= Files 44 44 Lines 7940 7940 Branches 1072 1072 ======================================= Hits 2767 2767 Misses 5061 5061 Partials 112 112 ``` | [Impacted Files](https://app.codecov.io/gh/atlassian-api/atlassian-python-api/pull/1203?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [atlassian/confluence.py](https://app.codecov.io/gh/atlassian-api/atlassian-python-api/pull/1203?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-YXRsYXNzaWFuL2NvbmZsdWVuY2UucHk=) | `13.16% <0.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.