Repository navigation
Distinguish transient from unsent errors in retry logic - #368
Merged
Merged
Conversation
…#336) AsyncTranscriptionClient.isTransient treated every URLError as transient, including URLError.cancelled, so cancelling a Library/Record transcription mid-poll burned all pollAttempts (with sleeps) before surfacing. It now retries only a named set of network codes (timeouts, dropped/unreachable connections), never a cancellation. The upload and submit were single-shot while only the status poll was retried, so one blip on POST /v2/upload lost a whole recording. Both now go through the same retry helper: the upload on any transient failure, the submit only when the API certainly created nothing (a 429, or a connection that never reached it), since repeating a submit that may have landed would bill a second transcript. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1WYcKDrTGM1dPNwV1h
The four retry tests pushed FileTranscriptionTests past swiftlint's 250-line type_body_length limit. They now live in AsyncTranscriptionRetryTests, and the scratch-audio-file helper both suites need moves to the shared test stubs rather than being copied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1WYcKDrTGM1dPNwV1h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The transcription client's retry logic now distinguishes between two categories of failures:
Transient errors (
isTransient): Network blips, timeouts, and server errors (5xx, 429) that may have reached the API. Safe to retry for polling and uploads, but not for non-idempotent POSTs like transcript submission, which could create duplicates.Unsent errors (
isUnsent): Connection failures that definitely never reached the server (DNS, cannot connect, etc.) plus 429s. Safe to retry for any operation, including transcript submission, since nothing was created server-side.This fixes a bug where transcript submissions timing out would not be retried (correct), but submissions that couldn't connect would also not be retried (incorrect—they're safe to retry). It also prevents cancelled requests from being retried, which would keep a Library cancel waiting through every retry attempt.
The changes:
retrying(when:)helperisUnsentto transcript submission (non-idempotent POST)isTransientto upload and polling (idempotent or read-only)ScriptedTransporttest helper for per-request response scriptingHow it was tested
Added
transientClassification()test covering all error categoriesAdded
cancelledPollNotRetried()test ensuring cancellations surface immediatelyAdded
uploadRetry()test verifying transient upload failures are retriedAdded
submitRetry()test verifying submit retry behavior differs by error typeAll new tests pass; existing tests remain green
scripts/check.shpasses (or CI will, if I'm not on a Mac)I read AGENTS.md and this doesn't reintroduce anything deliberately removed
Docs updated if behavior changed