Repository navigation
fix(api): handle suffix and out-of-bounds video ranges - #1620
Open
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Open
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
Conversation
Naveen Chatlapalli (1aifanatic)
requested review from
Cedric Vidal (cedricvidal) and
Wassim Chegham (manekinekko)
as code owners
November 4, 2026 22:20
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the video download byte-range changes.
No open issues 🎉
What changed in this PR
This PR fixes byte-range handling for Scope’s request-level and attempt-level video downloads, keeping response headers consistent with the bytes returned from storage.
Changes:
- Supports suffix and open-ended ranges, clamps end offsets, and returns 416 for unsatisfiable ranges before downloading.
- Adds route tests for supported, unsatisfiable, malformed, and unsupported ranges.
- Documents recording-download behavior and adds 416 responses to both OpenAPI artifacts.
| File | Description |
|---|---|
website/src/openapi/scope-openapi.json |
Adds documented 416 responses for both video endpoints. |
docs/architecture/app-design.md |
Describes byte-range support and fallback behavior. |
apps/api/src/routes/requests/video.ts |
Corrects range parsing, bounds handling, and response metadata. |
apps/api/src/routes/requests/video.test.ts |
Tests range responses and storage download offsets across both endpoints. |
apps/api/src/__snapshots__/openapi-snapshot.test.ts.snap |
Updates the API snapshot with 416 responses. |
Review effort: Balanced
This branch has not been deployed
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.
Summary
Video requests with a range extending past EOF advertised more bytes than storage returned, while suffix requests were ignored and unsatisfiable ranges reached storage with invalid offsets. Parse complete single-byte-range specifications, clamp end offsets, and support suffix/open-ended ranges.
For a 17-byte recording,
bytes=10-999now returns bytes 10–16,bytes=-5returns bytes 12–16, andbytes=17-returns 416 withContent-Range: bytes */17without a storage download. Unsupported units, malformed headers, and multipart ranges receive the complete 200 response.Testing
pnpm exec vitest run apps/api --maxWorkers=2— 809 passed, including the OpenAPI snapshot.pnpm --filter api exec tsc --noEmit— passed.pnpm test— 20 passed;SITE=https://microsoft.github.io BASE_PATH=/scope pnpm run build— passed, 227 pages.git diff --check— passed.Documentation and compatibility
Updated the API architecture documentation and both committed OpenAPI artifacts to describe 416 responses. No dependencies or migrations.
Demos
N/A — HTTP/storage behavior; no Portal or CLI component change. Route tests verify response status, range headers, body bytes, and storage offsets.