Skip to content

fix(api): handle suffix and out-of-bounds video ranges - #1620

Open
Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:fix/video-range-requests
Open

Naveen Chatlapalli (1aifanatic) wants to merge 1 commit into
microsoft:mainfrom
1aifanatic:fix/video-range-requests

Conversation

@1aifanatic

Copy link
Copy Markdown

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-999 now returns bytes 10–16, bytes=-5 returns bytes 12–16, and bytes=17- returns 416 with Content-Range: bytes */17 without a storage download. Unsupported units, malformed headers, and multipart ranges receive the complete 200 response.

Testing

  • 40 video route tests cover both request-level and attempt-level endpoints; 16 cases failed before the fix.
  • Node 22.23.3 / pnpm 10.29.1: pnpm exec vitest run apps/api --maxWorkers=2 — 809 passed, including the OpenAPI snapshot.
  • pnpm --filter api exec tsc --noEmit — passed.
  • Regenerated the website OpenAPI artifact from the production registry.
  • Website: 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.

@manekinekko Wassim Chegham (manekinekko) added area: api Scope REST API, run orchestration, SSE streaming, and endpoints. area: website Scope documentation website (Astro) under website/. community-contribution Pull requests submitted by external community contributors. language: javascript Work involving JavaScript code, tooling, or dependencies. topic: testing Test coverage, test infrastructure, and validation quality. type: bug Incorrect behavior or a regression that needs fixing. type: documentation Documentation additions, corrections, and improvements. labels Nov 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: api Scope REST API, run orchestration, SSE streaming, and endpoints. area: website Scope documentation website (Astro) under website/. community-contribution Pull requests submitted by external community contributors. language: javascript Work involving JavaScript code, tooling, or dependencies. topic: testing Test coverage, test infrastructure, and validation quality. type: bug Incorrect behavior or a regression that needs fixing. type: documentation Documentation additions, corrections, and improvements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants