Skip to content

fix(server): validate PUT /api/conversation request body as an object - #230

Open
aymanmali wants to merge 1 commit into
CopilotKit:mainfrom
aymanmali:fix/conversation-put-body-validation
Open

aymanmali wants to merge 1 commit into
CopilotKit:mainfrom
aymanmali:fix/conversation-put-body-validation

Conversation

@aymanmali

Copy link
Copy Markdown

Summary

PUT /api/conversation accessed body.messages before validating that the parsed JSON payload was an object, causing null or primitive JSON payloads (e.g. null, 123, "hello") to throw a TypeError and return 502 instead of 422.

Changes

  • Updated PUT /api/conversation in apps/server/src/app.ts to parse z.object({ messages: z.array(z.unknown()).max(1000) }) directly on the JSON payload.
  • Added regression test tests/conversation-body-validation.test.ts verifying null, primitive, and array payloads return 422.

Verification

  • pnpm format
  • pnpm lint
  • pnpm typecheck
  • pnpm test (524/524 passed)

This branch has not been deployed

No deployments
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