Skip to content

fix(core-ai): validate video fps and duration, and map aborted video calls to AbortError - #348

Merged
grabbou merged 2 commits into
mainfrom
fix/core-ai-validate-task-options
Oct 27, 2026
Merged

grabbou merged 2 commits into
mainfrom
fix/core-ai-validate-task-options

Conversation

@grabbou

@grabbou grabbou commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the CodeRabbit findings from the re-review of #315 and #326 that still apply to main. GitHub retargeted those PRs to main after the stack merged, so CodeRabbit re-reviewed code from the whole old stack under them.

Already fixed on main (by #340), so not changed here: tileSize, tileOverlap, topK, mean and std validation, and createTensor with plain number arrays for half-precision and 64-bit types. packages/core-ai/docs/getting-started.md moved to the website in #312.

Testing: 69 unit tests pass, typecheck and lint pass, and the iOS app compiles. Not run on the device, since the phone is in use for benchmarks.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Video generation now rejects nonpositive frame rates and invalid durations, including nonfinite, nonpositive, or over-one-hour durations, rather than failing during conversion.
    • Aborted video-generation requests now report a standard abort error. Other generation errors, such as out-of-memory errors, continue to be reported unchanged.
  • Documentation
    • Clarified that Apple’s vision-language engine does not support structured output, and that native sessions accept text prompts only. Use generateText or streamText with vision-language models.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 10:25
@vercel

vercel Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ai Ready Ready Preview Oct 27, 2026 10:58am UTC

Request Review

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: daa7a083-50e2-4cec-bec6-693e91036c1b
Commits

Reviewing files that changed from the base of the PR and between ceae07d and 02ffbc5.

Files selected for processing: 3
  • packages/core-ai/src/__tests__/ai-sdk.test.ts
  • packages/core-ai/src/ai-sdk.ts
  • website/src/docs/core-ai/generating.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

Video generation now rejects invalid FPS and duration inputs during iOS configuration. In TypeScript, generation errors become AbortError when the request signal is aborted; other errors pass through unchanged. The Apple VLM documentation now describes structured-output and session restrictions.

Changes: Video Generation

Layer / File(s) Summary
Video input validation
packages/core-ai/ios/CoreAIVideoGeneration.swift
makeConfiguration rejects nonpositive FPS. When deriving frame count from duration, it rejects nonfinite, nonpositive, and greater-than-3600-second values.
Video generation abort handling
packages/core-ai/src/ai-sdk.ts, packages/core-ai/src/__tests__/ai-sdk.test.ts
CoreAIVideoModel.generate converts errors to AbortError when the signal is aborted and rethrows other errors unchanged. Tests cover both outcomes.

Apple VLM Documentation

Layer / File(s) Summary
Apple VLM generation guidance
website/src/docs/core-ai/generating.md
The documentation states that Apple’s VLM engine rejects structured output with CORE_AI_UNSUPPORTED_CAPABILITY. It also says createSession() rejects vision language models and directs callers to generateText or streamText.

Priority: Normal

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

Change: Bug fix

Possibly related issues

  • Issue 344 asks for video generation to stop when the caller aborts. This change maps failures from aborted video generation to AbortError; it does not implement the issue’s progress reporting requirement.

Possibly related PRs

Merge Risk: Minimal · up to 02ffb

No merge-blocking correctness, availability, security, or documentation issue is established.

Security architecture risk: Minimal · up to 02ffb

The change tightens existing input validation and normalizes cancellation failures without expanding access or privileges. No material security risk introduced or worsened by this PR was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed path affects callers that already possess access to the native video API and the application process performing generation. The comparison shows no new entrypoint, credential use, cross-service access or higher-privilege sink. Existing native generation and temporary-file effects remain reachable through the same call path.

Trust Boundaries and Controls

  • observed — The new numeric checks execute in native configuration before the existing duration-to-frame conversion and video generation. They execute after pipeline loading, so they are not a pre-load resource control or comprehensive validation of every numeric option.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title matches the main change. The PR adds fps and duration validation to CoreAIVideoGeneration.swift and maps aborted video calls to AbortError in ai-sdk.ts, as the objectives and file summaries …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 50.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title matches the main change. The PR adds fps and duration validation to CoreAIVideoGeneration.swift and maps aborted video calls to AbortError in ai-sdk.ts, as the objectives and file summaries describe. The title is specific and follows the conventional-commit style, and it covers both parts of the change. It is somewhat long at 88 characters, but this does not make it unclear.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 50.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files. (1 skipped: 1 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

grabbou and others added 2 commits October 27, 2026 14:57
…calls to AbortError

A NaN, infinite or huge duration trapped in the frame count conversion and
stopped the app, and fps of 0 or below reached the MP4 writer. Both now
reject with CORE_AI_INVALID_INPUT. Native errors after an abort now reach
callers as an AbortError, as in the language model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ut and sessions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@grabbou
grabbou force-pushed the fix/core-ai-validate-task-options branch from ceae07d to 02ffbc5 Compare October 27, 2026 10:58
@grabbou
grabbou merged commit 8d298d4 into main Oct 27, 2026
10 checks passed
@grabbou
grabbou deleted the fix/core-ai-validate-task-options branch October 27, 2026 11:46

This branch was successfully deployed

1 active deployment
Preview — 02ffbc56 Deployed Oct 27, 2026 by vercel[bot]
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.

2 participants