fix(registry): replace unknown with proper WhereExpression Zod schema#87
Open
JonasJesus42 wants to merge 1 commit intomainfrom
Open
fix(registry): replace unknown with proper WhereExpression Zod schema#87JonasJesus42 wants to merge 1 commit intomainfrom
JonasJesus42 wants to merge 1 commit intomainfrom
Conversation
- Add WhereExpression type with recursive structure - Create recursive Zod schema using z.lazy() for proper validation - Support all operators: eq, gt, gte, lt, lte, in, like, contains, and, or, not - Improve type safety for filter expressions
🚀 Preview Deployments Ready!Your changes have been deployed to preview environments: 📦
|
Contributor
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="registry/server/tools/registry-binding.ts">
<violation number="1" location="registry/server/tools/registry-binding.ts:52">
P2: Type-schema mismatch: `operator` is typed as `string` but the schema validates against a specific enum. Consider using a union type to match the schema for better type safety: `operator?: 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'like' | 'contains' | 'and' | 'or' | 'not';`</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const WhereExpressionSchema = z.unknown(); | ||
| type WhereExpression = { | ||
| field?: string[]; | ||
| operator?: string; |
Contributor
There was a problem hiding this comment.
P2: Type-schema mismatch: operator is typed as string but the schema validates against a specific enum. Consider using a union type to match the schema for better type safety: operator?: 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'like' | 'contains' | 'and' | 'or' | 'not';
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At registry/server/tools/registry-binding.ts, line 52:
<comment>Type-schema mismatch: `operator` is typed as `string` but the schema validates against a specific enum. Consider using a union type to match the schema for better type safety: `operator?: 'eq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'like' | 'contains' | 'and' | 'or' | 'not';`</comment>
<file context>
@@ -44,9 +44,46 @@ const RegistryServerSchema = z.object({
-const WhereExpressionSchema = z.unknown();
+type WhereExpression = {
+ field?: string[];
+ operator?: string;
+ value?: unknown;
+ conditions?: WhereExpression[];
</file context>
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 by cubic
Replaced the registry filter schema with a recursive WhereExpression using Zod to validate nested conditions and operators. This improves type safety and prevents invalid filter payloads.
Written for commit ccc97ab. Summary will update on new commits.