Repository navigation
test(runtime): make run error tests reach the code they name, drop two that check nothing - #8204
Merged
Merged
Conversation
Three tests passed because any Response passed. The 500 error and 500 CORS tests sent a body without messages, so they got a 400 from validation and never reached the agent. The single-route onBeforeHandler test built a Request that throws (no duplex), so agent/run never ran. They now send a valid run body and assert the status they name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The MCPClient type test cast tools() with as unknown as and asserted expect(true). Without the cast an @ai-sdk/mcp MCPClient is not assignable to MCPClientProvider, so the test only hid that mismatch. The MCP Apps middleware test checked that a constructor returns an instance of its class. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 1
Please check the settings in the CodeRabbit UI or the
|
Contributor
|
Size Change: 0 B Total Size: 2.39 MB ℹ️ View Unchanged
|
@copilotkit/a2ui-renderer
@copilotkit/agentcore-runner
@copilotkit/angular
@copilotkit/channels
@copilotkit/channels-core
@copilotkit/channels-discord
@copilotkit/channels-intelligence
@copilotkit/channels-slack
@copilotkit/channels-teams
@copilotkit/channels-ui
@copilotkit/channels-whatsapp
@copilotkit/core
@copilotkit/intelligence-langgraph
@copilotkit/intelligence-mastra
@copilotkit/learning
@copilotkit/markdown
@copilotkit/mcp-apps-renderer
@copilotkit/react-core
@copilotkit/react-native
@copilotkit/runtime
@copilotkit/sdk-js
@copilotkit/shared
@copilotkit/sqlite-runner
@copilotkit/voice
@copilotkit/vue
@copilotkit/web-components
@copilotkit/web-inspector
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three runtime tests passed only because any
Responsepassed. None of them reached the code it names. This PR makes them reach it and assert the status. It also deletes two tests that check nothing. No production code changes.Part of PE-1086. v1 and the GraphQL runtime are already gone from
2.0.0(#8084, #8103), so nothing in runtime was skipped for pending removal.What does this PR do?
Rewritten
fetch-handler.test.ts› "returns 500 JSON error for unhandled errors"messages, so the request got a 400 from validation. The agent never ran. The test only checkedtoBeInstanceOf(Response).Invalid request body. Mutation M-A (the "Failed to run agent" response inhandle-run.tsreturns 200 instead of 500): the old test passes, the new one fails.fetch-handler-validation.test.ts› "CORS headers present on 500 error responses"code-review-fixes.test.ts› "single-route agent/run works after onBeforeHandler replaces request"new Request(..., { body: stream })withoutduplex, and that throws in Node. The handler returned a 500internal_errorandagent/runnever ran.onErrorshowedTypeError: RequestInit: duplex option is required. Mutation M-B (single-route dispatch sends{}instead ofmethodCall.bodyforagent/run): the old test passes, the new one fails.Each rewritten test now sends a valid run body and asserts the status it names: 500 with
{"error":"Failed to run agent","message":"boom"}, 500 with CORS headers, or 200 withtext/event-stream.Deleted
mcp-clients.test.ts› "type compatibility: @ai-sdk/mcp MCPClient satisfies MCPClientProvider"tools()withas unknown asand ended withexpect(true).toBe(true), so it checked nothing at runtime or compile time. Without the cast,tscrejects the claim (see below).mcp-apps-middleware-integration.test.ts› "can be created with mcpServers config pointing at MCPMock URL"new MCPAppsMiddleware(...)is an instance ofMCPAppsMiddleware. That is always true. The other tests in the file use the middleware.Finding for a follow-up (not fixed here)
An
@ai-sdk/mcpMCPClientis not assignable toMCPClientProvider. Itstools()returns MCP tools whoseinputSchemaisFlexibleSchema<unknown>, and that does not fit theaiToolSet. A user who passes a realMCPClienttomcpClientsgets a type error. The deleted test hid this with a cast. This PR changes tests only, so the type stays as it is.Related PRs and Issues
Checklist
!(not applicable)Testing
Commands run
nx run @copilotkit/runtime:test: 184 files and 3013 tests pass, 4 skipped.nx run @copilotkit/runtime:check-types --exclude-task-dependencies: passes.oxfmtand the oxlint gate on every changed file: pass.Manual test
packages/runtime/src/runtime/handlers/handle-run.ts, changestatus: 500in the "Failed to run agent" response tostatus: 200.pnpm vitest run src/runtime/__tests__/fetch-handler.test.tsinpackages/runtime.2.0.0, all tests pass. On this branch, "returns 500 JSON error for unhandled errors" fails.How this PR makes testing easy
The changes are tests only. The mutation steps above reproduce the evidence.
Risk / rollback
Low. Only test files change. To undo, revert the PR.
🤖 Generated with Claude Code