fix: validate project chat request bodies before side effects - #283
Merged
willchen96 merged 1 commit intoAug 4, 2026
Merged
Conversation
willchen96
approved these changes
Aug 4, 2026
Collaborator
|
Thanks for the contribution, let me know if you want to join the discord for contributors. |
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.
Summary
Validate project-chat request payloads at runtime before database, document-context, or LLM work. The shared parsers also keep
/chatand project chat from drifting apart.Closes #278. Supersedes the stale implementation in #155.
Why / Motivation
POST /projects/:projectId/chatpreviously trusted a TypeScript assertion. Malformed values could create a chat and reach downstream document and model work before failing.Changes
ask_inputs_response.userandassistant, normalize accepted strings, and return field-specific400details.Tradeoffs & risks
/chatnow applies the same strict role and nested-payload validation as project chat; malformed payloads that were previously tolerated return400.How verified
npm test --prefix backend -- --run src/lib/chat/__tests__/requestValidation.test.ts src/__tests__/integration/chat.routes.test.ts src/__tests__/integration/projectChat.routes.test.ts- 46 passed.npm test --prefix backend- 462 passed, 14 skipped.npm run build --prefix backendmessagescrossed database, document-context, and LLM seams on currentmain; the candidate route tests verify rejection before those seams.Checklist
git diffand removed unrelated changes..envfiles committed.