Skip to content

fix(video): parse multipart/form-data create body (OpenAI SDK 6.28+)#247

Merged
jpr5 merged 2 commits into
mainfrom
alem/video-create-multipart
Jun 3, 2026
Merged

fix(video): parse multipart/form-data create body (OpenAI SDK 6.28+)#247
jpr5 merged 2 commits into
mainfrom
alem/video-create-multipart

Conversation

@AlemTuzlak

Copy link
Copy Markdown
Contributor

Summary

The OpenAI SDK 6.28.0+ sends POST /v1/videos (videos.create) as multipart/form-data instead of JSON — even for File-less bodies (6.27 and earlier sent JSON when no File/Blob was present). aimock's handleVideoCreate only JSON.parses the body, so video-create requests from a current OpenAI SDK fail with 400 invalid_json.

This teaches the video handler to detect a multipart/form-data content-type and parse the prompt / model / size / seconds fields, reusing the existing exported extractBoundary / extractFormField transcription helpers (no new parser). seconds is coerced to a number to match the JSON shape. The JSON path (and its 400 invalid_json fallback) is preserved unchanged for older SDKs.

Why

Downstream consumers on openai@^6.28 (e.g. TanStack AI's E2E suite after bumping to 6.41) hit this — the mock 400s every video-create. This restores video-create compatibility with current OpenAI SDKs.

Changes

  • src/video.ts — content-type-aware body parse in handleVideoCreate (multipart branch + preserved JSON branch).
  • src/__tests__/multimedia.test.ts — new test posting a real FormData (multipart) video-create body and asserting the fixture matches.
  • CHANGELOG.md[Unreleased] › Fixed entry.

Test Plan

  • pnpm build — clean
  • pnpm lint — clean
  • prettier --check src/video.ts — clean
  • pnpm test src/__tests__/multimedia.test.ts — 25/25 (incl. the new multipart case)
  • Full pnpm test — the new test passes; the only failures are pre-existing Windows-local flakes unrelated to this change (cli.test.ts SIGTERM/exit-code, fixtures-remote.test.ts XDG_CACHE_HOME, timing-replay.test.ts replaySpeed timing — the failing count varied 3↔4 between runs). None touch video; CI (Linux) should be green.

Release

Compatibility fix → patch (e.g. 1.28.1) by the repo's precedent (cf. 1.27.3 "correct OpenAI images endpoint path"). The CHANGELOG entry sits under [Unreleased] for the maintainer to cut via pnpm release.

🤖 Generated with Claude Code

@pkg-pr-new

pkg-pr-new Bot commented Jun 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@247

commit: ab66cbb

AlemTuzlak added a commit to TanStack/ai that referenced this pull request Jun 3, 2026
…rop stopgap patch

@copilotkit/aimock now parses multipart/form-data video-create bodies natively
(CopilotKit/aimock#247), so the local pnpm patch is no longer needed. Bump the
e2e dependency to ^1.28.1 (the release carrying that fix) and remove the patch
file + patchedDependencies entry.

Note: CI is expected to be RED until @copilotkit/aimock >=1.28.1 is published —
the lockfile still resolves 1.27.0 and the unpatched mock 400s video-create.
Once the release is out, `pnpm install` refreshes the lockfile to 1.28.1 and the
video-gen E2E goes green.
AlemTuzlak and others added 2 commits June 3, 2026 11:51
The OpenAI SDK 6.28.0+ sends POST /v1/videos (videos.create) as
multipart/form-data instead of JSON — even for File-less bodies — which
handleVideoCreate previously rejected with 400 invalid_json. Detect the
multipart content-type and parse the prompt/model/size/seconds fields
(reusing the exported transcription multipart helpers), coercing numeric
fields to match the JSON shape; the JSON path is preserved for older SDKs.

Closes the regression where openai>=6.28 video-create requests fail against
the mock.
@jpr5 jpr5 force-pushed the alem/video-create-multipart branch from 2003b4d to ab66cbb Compare June 3, 2026 18:51
@jpr5 jpr5 merged commit 699bfb4 into main Jun 3, 2026
23 checks passed
@jpr5 jpr5 deleted the alem/video-create-multipart branch June 3, 2026 18:55
@AlemTuzlak AlemTuzlak mentioned this pull request Jun 4, 2026
AlemTuzlak added a commit that referenced this pull request Jun 4, 2026
## Release 1.29.0

Cuts the accumulated `[Unreleased]` changes as **1.29.0** (semver minor
— there are `Added` + `Deprecated` entries). Bumps `package.json`
`1.28.0 → 1.29.0` and moves the CHANGELOG `[Unreleased]` section under
`## [1.29.0] - 2026-06-04`.

**Merging to `main` triggers the Release workflow to publish `1.29.0` to
npm** (the workflow publishes when `package.json`'s version isn't yet on
the registry).

### What ships in 1.29.0

**Added**
- `POST /__aimock/reset/fixtures` and `POST /__aimock/reset/journal`
- `aimock-pytest`: `reset_fixtures()` / `reset_journal()`
- Control API reference docs

**Changed**
- `engines.node` lowered to `>=20.15.0`

**Deprecated**
- `POST /__aimock/reset` (alias for `/reset/fixtures`)

**Fixed**
- **Video** — `POST /v1/videos` now parses `multipart/form-data` bodies
(OpenAI SDK ≥6.28 sends video-create as multipart) — #247
- `aimock-pytest` per-fixture option forwarding +
startup-timeout/teardown hardening
- `DELETE /v1/_requests` clears only journal entries (preserves fixture
match-counts)

### Downstream
Unblocks **TanStack/ai#695**, which pins `@copilotkit/aimock: ^1.28.1`
and drops its temporary local video-multipart patch — once 1.29.0 is on
npm, that PR's E2E goes green.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
AlemTuzlak added a commit to TanStack/ai that referenced this pull request Jun 4, 2026
…695)

* feat(openai): support shell-tool skills via environment.skills

Add an optional `environment` config to `shellTool()` (ShellToolFactoryConfig)
so hosted provider Skills can ride the OpenAI Responses shell tool, e.g.
`shellTool({ environment: { type: 'container_auto', skills: [...] } })`. The
converter now passes `environment` through to the request.

Bumps the openai SDK to ^6.41.0 (required for the typed shell environment.skills
surface) across ai-openai, openai-base, ai-grok, and ai-groq, with the small
SDK-compat adjustments the bump requires (ComputerUsePreviewTool import; dropped
now-redundant casts in image.ts/video.ts).

* feat(anthropic): support code-execution skills via container.skills + beta headers

Add an optional `{ skills }` to `codeExecutionTool(config, options)`. The adapter
lifts those skills into the request's top-level `container.skills` (preserving any
`container.id`) and attaches the required beta headers via `computeAnthropicBetas`:
`code-execution-2025-08-25` (or `code-execution-2025-05-22` for the legacy
`code_execution_20250522` variant) plus `skills-2025-10-02` when skills are present.
Betas are now applied on both the streaming and structuredOutput request paths.

Skills set via `modelOptions.container.skills` are deprecated in favor of the tool
option. Adds unit tests for the lift, the version-aware betas, the skills/lift
agreement across multi-tool configs, and skill_id validation.

* test(e2e): cover provider skills; docs + skill; patch aimock video multipart

Add wire-assertion E2E for both providers (Anthropic container.skills + beta
headers; OpenAI shell environment.skills) plus the docs page (docs/tools/
provider-skills.md, nav + cross-links) and the tool-calling agent skill section.

The openai 6.41 bump makes videos.create send multipart/form-data, which the
pinned @copilotkit/aimock (1.27.0) only JSON-parses; add a pnpm patch teaching
its video handler to parse multipart (reusing the existing transcription
helpers), and give the video-gen fixture the id/status the flow needs. The same
fix should be upstreamed to @copilotkit/aimock so the patch can be dropped.

* chore(e2e): consume @copilotkit/aimock with native multipart video; drop stopgap patch

@copilotkit/aimock now parses multipart/form-data video-create bodies natively
(CopilotKit/aimock#247), so the local pnpm patch is no longer needed. Bump the
e2e dependency to ^1.28.1 (the release carrying that fix) and remove the patch
file + patchedDependencies entry.

Note: CI is expected to be RED until @copilotkit/aimock >=1.28.1 is published —
the lockfile still resolves 1.27.0 and the unpatched mock 400s video-create.
Once the release is out, `pnpm install` refreshes the lockfile to 1.28.1 and the
video-gen E2E goes green.

* chore(e2e): lock @copilotkit/aimock to 1.29.0

1.29.0 is published with native multipart/form-data video-create parsing,
satisfying the ^1.28.1 spec. Refreshes the lockfile off the now-removed local
patch; video-gen E2E passes natively against the published mock.
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