Skip to content

raise video import limit to 800 MiB - #2

Merged
starsstreaming merged 1 commit into
mainfrom
codex/video-import-800mib
Jul 30, 2026
Merged

raise video import limit to 800 MiB#2
starsstreaming merged 1 commit into
mainfrom
codex/video-import-800mib

Conversation

@starsstreaming

@starsstreaming starsstreaming commented Jul 30, 2026

Copy link
Copy Markdown
Owner

What changed

  • raise the default MP4 import limit from 500 MiB to 800 MiB
  • update the media contract documentation
  • add a regression test for the configured limit and oversized-file rejection

Why

Users can import larger local background videos without changing the existing streaming, validation, or saved-theme storage behavior.

Impact

Accepted MP4 files may now be up to 800 MiB. The 2 GiB saved-theme storage quota remains unchanged.

Validation

  • npm test (43 tests passed)
  • npm run typecheck
  • git diff --check

Summary by CodeRabbit

  • 功能改进

    • 视频文件大小上限从 500 MiB 提升至 800 MiB,支持处理更大的视频文件。
  • 文档

    • 更新视频验证规则,明确记录新的 800 MiB 文件大小上限。

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a04c79eb-4773-476b-a6a7-4c75093add54

📥 Commits

Reviewing files that changed from the base of the PR and between 9392ebb and 0d69bd4.

📒 Files selected for processing (3)
  • docs/media-contract.md
  • packages/core/src/constants.ts
  • packages/core/test/media-validation.test.js

📝 Walkthrough

Walkthrough

视频大小上限由 500 MiB 提高至 800 MiB,核心常量、媒体契约和视频校验测试同步更新。

Changes

视频大小限制更新

Layer / File(s) Summary
视频大小限制与验证
packages/core/src/constants.ts, packages/core/test/media-validation.test.js, docs/media-contract.md
MAX_VIDEO_BYTES 调整为 800 MiB,新增默认限制及超限拒绝测试,并将媒体契约中的视频大小上限更新为 800 MiB。

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/video-import-800mib

Comment @coderabbitai help to get the list of available commands.

@starsstreaming
starsstreaming marked this pull request as ready for review July 30, 2026 02:42
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@starsstreaming
starsstreaming merged commit dd3e641 into main Jul 30, 2026
8 of 9 checks passed
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Raise MP4 import limit to 800 MiB

✨ Enhancement 📝 Documentation 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Increase default MP4 import size limit from 500 MiB to 800 MiB.
• Update media contract documentation to reflect the new maximum video size.
• Add a regression test for the default limit and oversized-file rejection.
Diagram

graph TD
  A["Video import"] --> B["validateVideoFile"] --> C[("Local MP4 file")]
  B --> D["MAX_VIDEO_BYTES (800 MiB)"]
  E["media-validation.test.js"] --> B
  D --> F["docs/media-contract.md"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Make the max video size configurable (env/config file)
  • ➕ Allows deployments to tune limits for bandwidth/storage constraints
  • ➕ Avoids further code changes for future size adjustments
  • ➖ Adds configuration surface area and documentation burden
  • ➖ Requires validating/propagating config across build/runtime environments
2. Tiered limits by context (import vs publish vs storage quota)
  • ➕ More precisely enforces different constraints at each lifecycle step
  • ➕ Can prevent accepting imports that later fail publish/storage
  • ➖ More complex UX and error handling
  • ➖ Requires auditing other pipelines to ensure consistent enforcement

Recommendation: Keep the current approach (single shared MAX_VIDEO_BYTES constant) for now: it’s the smallest change that preserves existing validation and downstream behavior while raising the cap. Consider configuration-driven or tiered limits only if different deployments/users need divergent caps or if future constraints diverge between import/publish/storage.

Files changed (3) +20 / -2

Enhancement (1) +1 / -1
constants.tsIncrease MAX_VIDEO_BYTES constant to 800 MiB +1/-1

Increase MAX_VIDEO_BYTES constant to 800 MiB

• Raises the default maximum accepted video size by updating MAX_VIDEO_BYTES from 500 MiB to 800 MiB.

packages/core/src/constants.ts

Tests (1) +18 / -0
media-validation.test.jsAdd regression test for default 800 MiB limit and rejection +18/-0

Add regression test for default 800 MiB limit and rejection

• Imports MAX_VIDEO_BYTES from the built constants and asserts it equals 800 MiB. Adds an oversized-file test that truncates a fixture to MAX_VIDEO_BYTES + 1 and verifies validateVideoFile rejects with the expected limit message.

packages/core/test/media-validation.test.js

Documentation (1) +1 / -1
media-contract.mdDocument increased MP4 size limit to 800 MiB +1/-1

Document increased MP4 size limit to 800 MiB

• Updates the media contract rules table to raise the allowed MP4 size range ceiling from 500 MiB to 800 MiB.

docs/media-contract.md

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Huge truncate in test 🐞 Bug ☼ Reliability
Description
The new regression test expands a temp MP4 to MAX_VIDEO_BYTES+1 (838,860,801 bytes) via fs.truncate,
which assumes the filesystem makes this enlargement sparse/cheap. On environments that
allocate/reserve blocks for such truncation, this can consume ~800 MiB and make the test suite slow
or fail due to disk/quota limits.
Code

packages/core/test/media-validation.test.js[R84-92]

+  const root = await fs.mkdtemp(path.join(os.tmpdir(), "bc-video-limit-"));
+  try {
+    const oversized = path.join(root, "oversized.mp4");
+    await fs.writeFile(oversized, mp4Fixture());
+    await fs.truncate(oversized, MAX_VIDEO_BYTES + 1);
+    await assert.rejects(
+      () => validateVideoFile(oversized),
+      /no larger than 838860800 bytes/,
+    );
Evidence
The test explicitly truncates a file to 838,860,801 bytes, derived from MAX_VIDEO_BYTES=800 MiB, and
then calls validateVideoFile which rejects based on size > maxBytes. This introduces a dependency on
large-file creation behavior of the underlying filesystem/runner.

packages/core/test/media-validation.test.js[81-96]
packages/core/src/constants.ts[3-7]
packages/core/src/media-validation.ts[213-227]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`packages/core/test/media-validation.test.js` creates an oversized MP4 by truncating it to `MAX_VIDEO_BYTES + 1` (an 800 MiB+ logical file). This test relies on filesystem behavior that may not be consistent across CI runners (sparse vs. fully allocated truncation), which can lead to slow/flaky tests or disk/quota failures.

### Issue Context
`validateVideoFile()` rejects oversized inputs based on `stat.size` before hashing/reading the file, so the regression can be tested without requiring a huge logical file.

### Fix Focus Areas
- packages/core/test/media-validation.test.js[81-96]

### Suggested fix approach
- Keep the configuration assertion (`MAX_VIDEO_BYTES === 800 * 1024 * 1024`).
- For the oversized rejection behavior, prefer a small file and pass a small `maxBytes` override to `validateVideoFile(..., { maxBytes: <small> })` to exercise the same rejection branch and error formatting without creating an 800 MiB+ file.
- If you must specifically test the *default* path, consider refactoring validation to allow injecting a `stat` provider in tests (so size can be simulated) rather than creating very large files.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

Comment on lines +84 to +92
const root = await fs.mkdtemp(path.join(os.tmpdir(), "bc-video-limit-"));
try {
const oversized = path.join(root, "oversized.mp4");
await fs.writeFile(oversized, mp4Fixture());
await fs.truncate(oversized, MAX_VIDEO_BYTES + 1);
await assert.rejects(
() => validateVideoFile(oversized),
/no larger than 838860800 bytes/,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

1. Huge truncate in test 🐞 Bug ☼ Reliability

The new regression test expands a temp MP4 to MAX_VIDEO_BYTES+1 (838,860,801 bytes) via fs.truncate,
which assumes the filesystem makes this enlargement sparse/cheap. On environments that
allocate/reserve blocks for such truncation, this can consume ~800 MiB and make the test suite slow
or fail due to disk/quota limits.
Agent Prompt
### Issue description
`packages/core/test/media-validation.test.js` creates an oversized MP4 by truncating it to `MAX_VIDEO_BYTES + 1` (an 800 MiB+ logical file). This test relies on filesystem behavior that may not be consistent across CI runners (sparse vs. fully allocated truncation), which can lead to slow/flaky tests or disk/quota failures.

### Issue Context
`validateVideoFile()` rejects oversized inputs based on `stat.size` before hashing/reading the file, so the regression can be tested without requiring a huge logical file.

### Fix Focus Areas
- packages/core/test/media-validation.test.js[81-96]

### Suggested fix approach
- Keep the configuration assertion (`MAX_VIDEO_BYTES === 800 * 1024 * 1024`).
- For the oversized rejection behavior, prefer a small file and pass a small `maxBytes` override to `validateVideoFile(..., { maxBytes: <small> })` to exercise the same rejection branch and error formatting without creating an 800 MiB+ file.
- If you must specifically test the *default* path, consider refactoring validation to allow injecting a `stat` provider in tests (so size can be simulated) rather than creating very large files.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant