fix(localapi): reject over-limit inline audio instead of silently truncating#429
Open
postoso wants to merge 1 commit into
Open
fix(localapi): reject over-limit inline audio instead of silently truncating#429postoso wants to merge 1 commit into
postoso wants to merge 1 commit into
Conversation
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
The LocalAPI 300-second audio limit is enforced inconsistently. The file-path transcription route validates duration and returns an error, but inline/body uploads (base64 + raw POST) flow through
LocalAPIAudioDecoder.samples(from:), which didmin(file.length, maxFrames)and silently truncated audio past 300s. A client POSTing a 10-minute clip silently got back only the first 5 minutes transcribed.How
samples(from:)now guardsfile.length <= maxFramesand throws instead of truncating, so the shared decode path (used by both inline and file-path routes) rejects over-limit audio. ExtracteddurationLimitExceededError()and reused it invalidateDurationWithinLimit, so both routes return the byte-identical error (same HTTP 400). The under-limit path is behavior-identical.Tests
New
LocalAPIAudioDecoderTests(3 methods): inline over-limit throws, inline under-limit decodes normally, file-path over-limit throws. Synthetic silent WAV built in-memory (no ML model needed).xcodebuild testis green andswiftlint --strictis clean.