Skip to content
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

fix the manual add datapoint dialog #199

Merged
merged 1 commit into from
Nov 12, 2024
Merged

fix the manual add datapoint dialog #199

merged 1 commit into from
Nov 12, 2024

Conversation

dinmukhamedm
Copy link
Member

@dinmukhamedm dinmukhamedm commented Nov 12, 2024

Loosen the required restriction on the Zod schema + add a warning on invalid JSONs


Important

Loosen schema restrictions and add JSON validation feedback in manual add datapoint dialog.

  • Schema Changes:
    • Loosen metadata field restriction in CreateDatapointsSchema from z.record(z.any()) to z.any() in route.ts.
    • Remove .required() from CreateDatapointsSchema.safeParse() in route.ts.
  • Validation:
    • Add isValidJson function in manual-add-datapoint-dialog.tsx to check JSON validity and presence of data field.
    • Display warning message if JSON is invalid in manual-add-datapoint-dialog.tsx.
  • Error Handling:
    • Update error message to show specific details from response in manual-add-datapoint-dialog.tsx.

This description was created by Ellipsis for e7d8678. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Changes requested. Reviewed everything up to e7d8678 in 1 minute and 28 seconds

More details
  • Looked at 76 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_DTPBwvI1hu0BBdIH


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@@ -32,7 +32,7 @@ const CreateDatapointsSchema = z.object({
datapoints: z.array(z.object({
data: z.unknown(),
target: z.any().optional(),
metadata: z.record(z.any()).optional(),
metadata: z.any().optional(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using z.any() for metadata is too permissive. Consider using a more specific schema to ensure data integrity.

Suggested change
metadata: z.any().optional(),
metadata: z.object().optional(),

@dinmukhamedm dinmukhamedm merged commit 9483523 into dev Nov 12, 2024
1 check passed
@dinmukhamedm dinmukhamedm deleted the fix/manual-add-dp branch November 12, 2024 19:40
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