Skip to content

Conversation

@awalker4
Copy link
Collaborator

@awalker4 awalker4 commented Aug 22, 2024

We discovered that when a pdf is split into smaller chunks, those requests are not being retried. Now that we have allow_failed=False, this results in the whole document failing as soon as any of the child requests hit a transient error. The fix is to reuse the utils.Retry logic that the main code path uses. Copying the retry config in the hook logic is not great, and we can work with Speakeasy to make the internal logic more modular so we can reuse more. But for now, this will address the current failures while we work on a better implementation.

Testing:
See the added unit test. The existing retry logic works for the final split page, everything else needs to use the new logic. To test this, I mocked a response from the server to return 502 for a low starting_page_number, which we know will have to be handled by the hooks.

Other changes:
Remove the "Not splitting" log. When the final split page is retried, it triggers all the hooks again. We need to force split_pdf_page=False in this request, and we don't need additional logging when this code is hit again.

We discovered that when a pdf is split into smaller chunks, those requests are not being
retried. Now that we have `allow_failed=False`, this results in the whole document failing as soon
as any of the child requests hit a transient error. The fix is to reuse the `utils.Retry` logic that
the main code path uses. Copying the retry config in the hook logic is not great, and we can work
with Speakeasy to make the internal logic more modular. But for now, this will address the current
failures while we work on a better implementation.

Testing:
See the added unit test. The existing retry logic works for the final split page, everything else
needs to use the new logic. To test this, I mocked a response from the server to return 502 for a
low `starting_page_number`, which we know will have to be handled by the hooks.
@awalker4 awalker4 requested a review from MKhalusova August 22, 2024 05:27
Copy link
Contributor

@pawel-kmiecik pawel-kmiecik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a nit but LGTM!

@awalker4 awalker4 force-pushed the fix/retry-split-requests branch from c385af5 to f18f2b4 Compare August 22, 2024 13:35
@awalker4 awalker4 enabled auto-merge (squash) August 22, 2024 13:37
@awalker4 awalker4 disabled auto-merge August 22, 2024 13:42
@awalker4 awalker4 enabled auto-merge (squash) August 22, 2024 14:18
@awalker4 awalker4 merged commit 0410784 into main Aug 22, 2024
@awalker4 awalker4 deleted the fix/retry-split-requests branch August 22, 2024 14:47
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

Successfully merging this pull request may close these issues.

3 participants