Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

From Discord: Enhancing Debugging with Custom Error Messages in Schema Validation #2482

Closed
effect-bot opened this issue Apr 5, 2024 · 0 comments · Fixed by #2483 or #2480
Closed
Assignees
Labels

Comments

@effect-bot
Copy link

Summary

The discussion revolves around enhancing debugging capabilities in schema validation within the Effect-TS ecosystem, specifically focusing on adding custom error messages to make it easier to identify which model caused an issue during schema validation.

Key Points:

  1. Custom Error Messages for Debugging: The conversation starts with a request for a way to include custom error messages, such as including an ID in the error message, to help identify which part of a complex schema failed during validation.

  2. Issue with Empty Arrays: There was confusion about why an empty array was causing an error in a schema expected to handle arrays, not just non-empty arrays. This was resolved when it was discovered that a JSON.parse(JSON.stringify()) operation was causing issues, which was fixed by ensuring proper parsing and defaulting to an empty array when necessary.

  3. Solution for Custom Error Messages: The solution proposed involves using the S.message function from the Effect-TS schema library to customize error messages. However, this approach has the drawback of losing the rest of the default error message.

  4. Proposed Feature - Annotation for Error Identification: A new type of annotation was proposed to allow for a custom function that can extract and return key identifiers (like an ID) from the data being validated. This would allow for more informative error messages without losing the context provided by the default error messages.

  5. Naming the New Annotation: The discussion also touched on what to name this new annotation, with suggestions like "summary", "synopsis", "debug", "log", and finally settling on "parseIssueTitle" for its specificity to the use case at hand.

  6. Humor and Naming Challenges: Throughout the conversation, there were light-hearted exchanges about the challenges of naming variables and functions, as well as playful remarks about the participants' names.

Key Takeaways:

  • Custom error messages can significantly enhance the debugging process by providing clearer context on where and why a schema validation failed.
  • The Effect-TS schema library is flexible and allows for custom annotations, which can be leveraged to improve error reporting.
  • The community around Effect-TS is actively discussing and proposing solutions to make the library more user-friendly and effective for developers.
  • Naming is both a technical and a creative challenge in software development, as evidenced by the humorous exchanges about naming the new annotation.

Discord thread

https://discord.com/channels/795981131316985866/1225129212025770024

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
2 participants