-
Notifications
You must be signed in to change notification settings - Fork 754
[Error Boundaries] Add Zod schema for InfraErrorData validation #5617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f5826c5 to
8ae51b2
Compare
- Add InfraErrorDataSchema using z.discriminatedUnion for type-safe validation - Replace manual isInfraErrorData type guard with Zod safeParse - Infer InfraErrorData type from schema to keep type and validation in sync This ensures runtime validation matches the TypeScript type definition, reducing the risk of mismatches between the two.
- Add schemas for serialized error shapes that cross React Router boundary: - SerializedGatewayConnectionErrorSchema - SerializedAuthenticationErrorSchema - SerializedRouteNotFoundErrorSchema - SerializedClickHouseErrorSchema - SerializedAutopilotUnavailableErrorSchema - Replace manual object property checks with Zod safeParse() - Reduces boilerplate while keeping validation centralized The schemas validate error objects after serialization where instanceof checks fail. Each type guard still uses instanceof for server-side checks.
e09e8af to
a506597
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Adds Zod schema validation for
InfraErrorData, replacing the manual type guard with schema-based validation. This ensures runtime validation matches the TypeScript type definition.Changes
InfraErrorDataSchemausingz.discriminatedUnionfor type-safe validationisInfraErrorDatatype guard withInfraErrorDataSchema.safeParse()InfraErrorDatatype from schema to keep type and runtime validation in syncBefore
After
PR Stack
Test plan
Important
Add Zod schema validation for
InfraErrorDataand serialized error schemas inerrors.tsfor improved runtime validation and error handling.InfraErrorDataSchemausingz.discriminatedUnionfor type-safe validation inerrors.ts.isInfraErrorDatatype guard withInfraErrorDataSchema.safeParse().InfraErrorDatatype fromInfraErrorDataSchemato ensure type and runtime validation sync.SerializedGatewayConnectionErrorSchema,SerializedAuthenticationErrorSchema,SerializedRouteNotFoundErrorSchema,SerializedClickHouseErrorSchema, andSerializedAutopilotUnavailableErrorSchemainerrors.ts.isGatewayConnectionError,isAuthenticationError,isGatewayEndpointNotFoundError,isClickHouseError, andisAutopilotUnavailableErrorto use respective serialized schemas inerrors.ts.This description was created by
for a506597. You can customize this summary. It will automatically update as commits are pushed.