Add Zod validation to server actions and API chat route; replace root interfaces with Zod schemas#197
Draft
Add Zod validation to server actions and API chat route; replace root interfaces with Zod schemas#197
Conversation
- Replace `interface MarkdownSection`, `interface PagePath` in docs.ts with Zod schemas + `z.output<typeof schema>` types - Add `ReplacedRangeSchema` and `DynamicMarkdownSectionSchema` to docs.ts, moving the type definitions out of the client-only pageContent.tsx - Remove `interface ReplacedRange` from multiHighlight.tsx; re-export `ReplacedRange` type from @/lib/docs - Remove `interface DynamicMarkdownSection` from pageContent.tsx; re-export `DynamicMarkdownSection` type from @/lib/docs - Replace `ReplOutputType` union, `ReplOutput`, `UpdatedFile`, `ReplCommand` interfaces in packages/runtime/src/interface.ts with Zod schemas + `z.output<typeof schema>` types; add zod dependency to runtime package - Replace `type ChatParams` in route.ts with `ChatParamsSchema` + Zod validation of POST request body (returns 400 on invalid input) - Add `z.string().uuid()` validation to deleteChat and getRedirectFromChat server action parameters Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
my-code | 2d6a4d9 | Commit Preview URL Branch Preview URL |
Mar 18 2026, 01:23 PM |
Copilot
AI
changed the title
[WIP] Add Zod validation for ServerAction parameters
Add Zod validation to server actions and API chat route; replace root interfaces with Zod schemas
Mar 18, 2026
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.
app/actions/server action parameters and theapp/api/chat/POST body lacked runtime validation. Types likeMarkdownSection,ReplCommand, etc. were defined as bare interfaces, requiring a separate schema to validate — so the types themselves are rewritten as Zod schemas withz.output<typeof schema>.Type definitions replaced with Zod schemas
app/lib/docs.ts—interface PagePath→PagePathSchema,interface MarkdownSection→MarkdownSectionSchema. Also addsReplacedRangeSchemaandDynamicMarkdownSectionSchema(consolidated here from client files to make schemas server-importable).packages/runtime/src/interface.ts—ReplOutputType,ReplOutput,UpdatedFile,ReplCommandinterfaces all replaced with Zod schemas +z.output<>types. Addedzodto the package's deps.app/markdown/multiHighlight.tsx/pageContent.tsx— localinterface ReplacedRange/interface DynamicMarkdownSectionremoved; re-export the types from@/lib/docs.Validation added
app/api/chat/route.ts—type ChatParamsreplaced byChatParamsSchema(composed from all sub-schemas above); POST body is now validated viasafeParse, returning HTTP 400 on invalid input.app/actions/deleteChat.ts/app/actions/getRedirectFromChat.ts—chatIdparameter validated withz.string().uuid()before use.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
workers.cloudflare.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node node node_modules/.bin/next lint(dns block)If you need me to access, download, or install something from one of these locations, you can either:
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.