Repository navigation
fix(io): a refused source fails with its HTTP status, not as invalid data (#378) - #379
Conversation
…data (superuser404notfound#378) An origin that answers the source request with a status instead of media (a 401/403 refusal, a 404, a 5xx) reached the host as `sourceOpenFailed` carrying FFmpeg's "Invalid data found when processing input": the forward-only streaming delegate allowed any status, so the error page went into the stream buffer and was probed as container bytes, and the 403 the ranged data connection had already been refused with was read by open() as "resolved no size". Nothing in the superuser404notfound#376 classification could tell a refused origin from a corrupt file. - The streaming GET hangs up at the response header on anything but a 200/206 and open() fails typed with `AVIOReaderError.httpStatus`, which `HLSVideoEngine.openFailure(from:)` passes through like the HLS classifications and load() publishes as the new `PlaybackErrorKind.sourceRefused` with `underlyingCode` = the status. - After a 401/403/404/410 on the open-time data connection the HEAD and `bytes=0-1` size probes are skipped: the one request still made is the unranged GET, so an origin that refuses `Range` but serves a plain GET plays forward-only, and one that refuses both fails with its status. 5xx and 429/503/509 keep the probe ladder. - The tail-prefetch "no suffix range support" latch (superuser404notfound#281) is set only by the origin's answer to the range form (a 200 that ignored it, a 416). A 401/403/404/429/5xx on that request neither latches nor counts as a transport strike, so one refusal no longer disables the prefetch for the origin for the rest of the process. Measured against a scripted loopback origin (HEAD 200/0, GET 403 with an error page; Range-refusing origin; 416 to the suffix form). Co-Authored-By: Claude Fable 5 <[email protected]>
fix(io): a refused source fails with its HTTP status, not as invalid data (#378)
79ba1b6
into
superuser404notfound:main
…rges the budget (#378 follow-up) Two things #379 could not know, because both landed on main after it was written (#377, 6.28.0). The reader now types the origin's answer to the open, and load() published all of it as sourceRefused. But #377 split the rate-limit shapes off for a reason: 429/503/509 means the source is being metered, not lost, so the host is told to wait rather than to hand off to a second player that the same origin will meter in turn. Publishing a metered open as sourceRefused hands a host the one verdict that contract exists to prevent. A 429/503/509 now publishes sourceRateLimited with the status in underlyingCode; every other status keeps sourceRefused. The second is a hole in the #377 accounting rather than in #379. A metering origin is charged wherever a status is first read, and the streaming pump was the one path that read one without charging it. On a sequential origin that GET is the session's only request, no ranged open and no probe by construction, so its 429 was seen by nobody: the budget kept offering that origin its full concurrency, and the revive arm had no stamp saying the source was metered rather than gone. The live source the comment first named was the wrong example, and the test said so: with prefetch on, a live open goes through the persistent connection, which charges the budget already. The sequential origin is the real gap. 1901 tests green. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01E5UztmCZtNYPQpzdmSdmWG
|
Merged as abbcd90. Thank you for this one: the diagnosis was exact down to the line, and the shape you picked (typed reader error passed through `openFailure(from:)`, additive kind on a string-backed struct) is the one the file already uses, so there was nothing to argue about. The scripted-origin tests are what made the probe-skip claim checkable rather than plausible. The branch was written against 6.26.0 and main has since taken #377 (6.28.0), so two things were pulled in afterwards, in 4bb63c8:
The comment there first named a raw live source as the case, and the test said otherwise: with prefetch on, a live open goes through the persistent connection, which charges the budget already. The sequential origin is the real gap. Conflicts were only in CHANGELOG.md and docs/api.md; the sources merged clean. 1901 tests green, CI green on main. Release still to be cut, and the issue stays open for the on-device retest you offered. |
Fixes #378.
What
An origin that answers the source request with an HTTP status instead of media (a 401/403 refusal, a 404, a 5xx) reached the host as
sourceOpenFailedcarrying FFmpeg's "Invalid data found when processing input", indistinguishable from a corrupt file — and one 403 on the tail prefetch switched the prefetch off for the origin for the rest of the process.StreamingDelegatehangs up at the response header on anything but a 200/206 and records the status;open()fails typed with a newAVIOReaderError.httpStatus(Int)(the AE#140/AE#154 shape).HLSVideoEngine.openFailure(from:)passes it through like the HLS classifications, andload()publishes it as the newPlaybackErrorKind.sourceRefusedwithunderlyingCode= the status (additive; the struct is string-backed for exactly this).underlyingDomainstays nil: the sentence is the engine's.bytes=0-1probes are skipped; the one request still made is the unranged GET, so an origin that refusesRangebut serves a plain GET plays forward-only, and one that refuses both fails with its status. 5xx and 429/503/509 keep the ladder (and their seekability).bytes=-nor a 416 still latches (VOD cold-start pays a mandatory sequential head→tail→re-anchor round trip on non-fast-start MP4 sources — request for parallel fetch or moov-offset hint #281 stays); a 401/403/404/429/5xx neither latches nor counts as a transport strike.A
readStreamingsafety net returns EIO (not EOF) if the refusing header arrives afteropen()'s 15 s budget — untyped, but never "invalid data" for a refusal.Why this shape
sourceRefusedrather than an HTTP domain onsourceOpenFailed: the Machine-readable companion to.error(String)so a host can classify a failure #376 docs say a non-nilunderlyingDomainmarks OS-localized text, and.vodSourceFailedis the precedent for "the kind says whatunderlyingCodemeans".isResolvedExpiryStatus(401/403/404/410), the predicate the file already treats as "not transient"; a HEAD from the same client is answered the same way, and a size learned from it would only re-issue the refused range on the persistent path, which then dies after one retry with the status lost.Test plan
swift test: 1874 Swift Testing tests + XCTest, all green on macOS 26 / Xcode 26.Issue378SourceRefusedTestsagainst a scripted loopback origin: HEAD 200/0 + GET 403 with an error page →open()throwshttpStatus(403),cumulativeBytesFetched == 0, exactly one suffix request, one unranged GET, no HEAD /bytes=0-1; the latch stays clear and a second open asks the suffix form again; a 416 still latches; a Range-refusing origin plays forward-only without probes;sequentialOnlyis typed too;Demuxer.openthrows the reader error, notDemuxerError;openFailure(from:)passes it through;publishLoadFailurepublishessourceRefused/403 vssourceOpenFailed.PublicAPIDocumentationTests/DocumentedConstantsTestsgreen;docs/api.mdnames the kind and the contract,docs/architecture.mdthe reader behaviour.max_connections=1panel (the reported origin) — the host now receivessourceRefused/ 403 during the slot-held window and plays once the slot frees; will confirm on-device after the release lands in the host's pin.🤖 Generated with Claude Code