Skip to content

feat: better YAML parsing error reporting #5750

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fbricon
Copy link
Contributor

@fbricon fbricon commented May 20, 2025

Description

When config.yaml doesn't conform to the expected schema, the reported error is somewhat cryptic. This PR adds zod-validation-error to render more user-friendly error messages (until prettifyError() becomes available in the next zod 4.0)

Checklist

  • I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screenshots

Before:
Screenshot 2025-05-20 at 14 33 02

After:
Screenshot 2025-05-19 at 16 08 47

Tests

  • Added packages/config-yaml/src/load/unroll.test.ts
  • To test manually, add this snippet to your config.yaml (name property is missing):
data:
  - destination: http://localhost:3000

Summary by cubic

Improved YAML config error messages by using zod-validation-error, making validation issues easier to understand.

  • Dependencies
    • Added zod-validation-error and updated zod to 3.24.4.

@fbricon fbricon requested a review from a team as a code owner May 20, 2025 12:41
@fbricon fbricon requested review from RomneyDa and removed request for a team May 20, 2025 12:41
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 20, 2025
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Copy link

netlify bot commented May 20, 2025

Deploy Preview for continuedev ready!

Name Link
🔨 Latest commit 7f60f16
🔍 Latest deploy log https://app.netlify.com/projects/continuedev/deploys/682d9b657fb51f0008c21182
😎 Deploy Preview https://deploy-preview-5750--continuedev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

core/data/log.ts Outdated
@@ -146,7 +146,7 @@ export class DataLogger {
event.data,
event.name,
schema,
zodSchema,
zodSchema as unknown as AnyZodObject,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

With zod 3.24.4, required by zod-validation-error, compilation fails with:

Argument of type 'ZodObject<Pick<{ eventName: ZodString; schema: ZodString; userId: ZodString; userAgent: ZodString; selectedProfileId: ZodString; } & { ...; }, "timestamp" | ... 29 more ... | "disableInFiles">, "strip", ZodTypeAny, { ...; }, { ...; }> | ... 7 more ... | ZodObject<...>' is not assignable to parameter of type 'AnyZodObject'.
Type 'ZodObject<Pick<{ eventName: ZodString; schema: ZodString; userId: ZodString; userAgent: ZodString; selectedProfileId: ZodString; } & { ...; }, "timestamp" | ... 29 more ... | "disableInFiles">, "strip", ZodTypeAny, { ...; }, { ...; }>' is not assignable to type 'ZodObject<any, any, any, { [x: string]: any; }, { [x: string]: any; }>'.
Types have separate declarations of a private property '_cached'.

If someone can come up with a better solution than this fugly hack, I'll be glad to apply it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@fbricon Wondering if this is because zod isn't updated in core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RomneyDa you're exactly right, nice catch. I set "zod":"^3.25.13" consistently and could remove
that hack.

Copy link
Collaborator

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

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

looks good, appreciate the tests. See comment!

@fbricon fbricon force-pushed the yaml-validation branch 4 times, most recently from b6835fb to 7f60f16 Compare May 21, 2025 09:22
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs May 22, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 22, 2025
@RomneyDa RomneyDa closed this May 22, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs May 22, 2025
@RomneyDa RomneyDa reopened this May 22, 2025
@github-project-automation github-project-automation bot moved this from Done to In Progress in Issues and PRs May 22, 2025
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2025
@RomneyDa
Copy link
Collaborator

RomneyDa commented May 24, 2025

@fbricon it seems like this is actually failing tests, something with the updated package locks maybe?

Signed-off-by: Fred Bricon <fbricon@gmail.com>
@fbricon fbricon force-pushed the yaml-validation branch from 7f60f16 to 119995b Compare May 26, 2025 07:47
@continuedev continuedev unlocked this conversation May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants