Skip to content

fix(aimock): validate fixtures at load time to prevent runtime 500s - #3973

Merged
jpr5 merged 3 commits into
mainfrom
fix/aimock-validate-on-load
Apr 16, 2026
Merged

jpr5 merged 3 commits into
mainfrom
fix/aimock-validate-on-load

Conversation

@jpr5

@jpr5 jpr5 commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up hardening to #3971. aimock supports fixture schema validation at startup via --validate-on-load, but the flag is opt-in and the showcase Dockerfile was not passing it. That meant fixtures with unrecognized response keys (e.g. "text" instead of "content") loaded silently and only surfaced as HTTP 500s at request time — which is exactly what crashed crewai-crews and triggered #3971.

This PR wires up two independent safety nets so a broken fixture can't ship again:

  1. Dockerfile (fail-fast at container boot) — showcase/aimock/Dockerfile now passes --validate-on-load. If any fixture fails the aimock schema, the container exits non-zero instead of starting and serving 500s. Railway will not promote a bad build.
  2. CI test (fail-fast in PR review) — new vitest spec at showcase/scripts/__tests__/aimock-fixtures.test.ts imports loadFixtureFile + validateFixtures from @copilotkit/aimock and asserts zero errors against both feature-parity.json and smoke.json. Runs inside the existing Showcase: Validate workflow (showcase/scripts vitest suite) on every PR that touches showcase/**.

Verification

Red-green on the vitest spec:

Red-green on the Dockerfile:

  • Current fixtures + --validate-on-load: container boots cleanly, logs Loaded 39 fixture(s) from /fixtures.
  • Injecting an intentionally broken fixture (response: { "text": "..." }): container fails to start with [aimock] Fixture 0: response is not a recognized type (must have content, toolCalls, error, or embedding) / Validation failed: 1 error(s), 0 warning(s) and non-zero exit.

Test plan

  • Local: full showcase/scripts vitest suite passes (549/549)
  • Local: pnpm run test (monorepo) passes
  • Docker: image builds and starts with --validate-on-load against current fixtures
  • Docker red-green: broken fixture fails container start with non-zero exit
  • CI: Showcase: Validate job runs the new test file on PR

Follow-up to #3971. aimock supports fixture schema validation at startup via
--validate-on-load, but it's opt-in. The showcase Dockerfile did not pass
the flag, so fixtures with unrecognized response keys (e.g. "text" instead
of "content") loaded silently and only failed at request time with HTTP 500.
That's what crashed crewai-crews on startup.

Changes:
- showcase/aimock/Dockerfile: pass --validate-on-load so broken fixtures
  fail the container boot, not individual requests.
- showcase/scripts/__tests__/aimock-fixtures.test.ts: new vitest spec that
  loads feature-parity.json and smoke.json via @copilotkit/aimock's
  loadFixtureFile + validateFixtures and asserts zero errors. Runs as part
  of the existing showcase-validate CI workflow.
- showcase/scripts/package.json: add @copilotkit/aimock dependency for the
  validator import.

Verified red-green: with the pre-#3971 broken "text" fixtures, validateFixtures
flags 5 errors; post-#3971 it returns zero. Docker red-green: container with
an intentionally broken fixture fails to start with "Validation failed: 1
error(s)" and non-zero exit.
@vercel

vercel Bot commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 16, 2026 8:18pm
research-canvas Ready Ready Preview, Comment Apr 16, 2026 8:18pm
travel Ready Ready Preview, Comment Apr 16, 2026 8:18pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
chat-with-your-data Skipped Skipped Apr 16, 2026 8:18pm
form-filling Skipped Skipped Apr 16, 2026 8:18pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

- Add --validate-on-load to all aimock invocations (4 workflows/scripts
  + 13 integration docker-compose files)
- Replace hardcoded 2-file fixture list with dynamic discovery across
  showcase/, examples/integrations/*/, scripts/doc-tests/ (16 fixtures)
- Add sanity check to prevent silent zero-test pass when discovery fails
- Extend showcase_validate.yml path filter to trigger on
  examples/integrations/**/fixtures/** and scripts/doc-tests/fixtures/**
- Import and use ValidationResult type for callback parameters
- Fix scripts/doc-tests/fixtures/default.json to use { fixtures: [...] }
  envelope shape
@vercel
vercel Bot temporarily deployed to Preview – chat-with-your-data April 16, 2026 20:14 Inactive
@vercel
vercel Bot temporarily deployed to Preview – form-filling April 16, 2026 20:14 Inactive
@jpr5
jpr5 merged commit 8424575 into main Apr 16, 2026
27 checks passed
@jpr5
jpr5 deleted the fix/aimock-validate-on-load branch April 16, 2026 20:34
jpr5 added a commit that referenced this pull request Apr 16, 2026
Adds showcase/aimock/README.md covering: what aimock is and why the
showcase uses it; the roles of feature-parity.json and smoke.json;
the hand-maintained sync policy and its two layers of load-time
schema validation (Dockerfile --validate-on-load + CI fixture test
from #3973); how to add/update a fixture; drift risk surfaces and
response; and the CI workflows that exercise the fixtures.
jpr5 added a commit that referenced this pull request Apr 16, 2026
Adds showcase/aimock/README.md covering: what aimock is and why the
showcase uses it; the roles of feature-parity.json and smoke.json;
the hand-maintained sync policy and its two layers of load-time
schema validation (Dockerfile --validate-on-load + CI fixture test
from #3973); how to add/update a fixture; drift risk surfaces and
response; and the CI workflows that exercise the fixtures.
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…opilotKit#3973)

## Summary

Follow-up hardening to CopilotKit#3971. aimock supports fixture schema validation
at startup via `--validate-on-load`, but the flag is **opt-in** and the
showcase Dockerfile was not passing it. That meant fixtures with
unrecognized response keys (e.g. `"text"` instead of `"content"`) loaded
silently and only surfaced as HTTP 500s at request time — which is
exactly what crashed crewai-crews and triggered CopilotKit#3971.

This PR wires up two independent safety nets so a broken fixture can't
ship again:

1. **Dockerfile (fail-fast at container boot)** —
`showcase/aimock/Dockerfile` now passes `--validate-on-load`. If any
fixture fails the aimock schema, the container exits non-zero instead of
starting and serving 500s. Railway will not promote a bad build.
2. **CI test (fail-fast in PR review)** — new vitest spec at
`showcase/scripts/__tests__/aimock-fixtures.test.ts` imports
`loadFixtureFile` + `validateFixtures` from `@copilotkit/aimock` and
asserts zero errors against both `feature-parity.json` and `smoke.json`.
Runs inside the existing ` Showcase: Validate` workflow
(`showcase/scripts` vitest suite) on every PR that touches
`showcase/**`.

## Verification

**Red-green on the vitest spec:**
- Rebased onto the tip of main *before* CopilotKit#3971 merged: the spec fails
with 5 errors — exactly the 5 broken `"text"` fixtures (`plan`, `steps`,
`mars`, `dashboard`, `report`) that CopilotKit#3971 repaired.
- Rebased forward onto main *after* CopilotKit#3971: spec passes with 0 errors,
all 549 showcase/scripts tests green.

**Red-green on the Dockerfile:**
- Current fixtures + `--validate-on-load`: container boots cleanly, logs
`Loaded 39 fixture(s) from /fixtures`.
- Injecting an intentionally broken fixture (`response: { "text": "..."
}`): container fails to start with `[aimock] Fixture 0: response is not
a recognized type (must have content, toolCalls, error, or embedding)` /
`Validation failed: 1 error(s), 0 warning(s)` and non-zero exit.

## Test plan

- [x] Local: full `showcase/scripts` vitest suite passes (549/549)
- [x] Local: `pnpm run test` (monorepo) passes
- [x] Docker: image builds and starts with `--validate-on-load` against
current fixtures
- [x] Docker red-green: broken fixture fails container start with
non-zero exit
- [ ] CI: ` Showcase: Validate` job runs the new test file on PR

This branch was successfully deployed

3 active and 2 inactive deployments
Preview – research-canvas — 513d72eb Deployed Apr 16, 2026 by vercel[bot]
Preview – travel — 513d72eb Deployed Apr 16, 2026 by vercel[bot]
Preview – docs — 513d72eb Deployed Apr 16, 2026 by vercel[bot]
Preview – chat-with-your-data — 513d72eb Deployed Apr 16, 2026 by vercel[bot]
Preview – form-filling — 513d72eb Deployed Apr 16, 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.

1 participant