Skip to content

OCapN: improved error messages and testing #2772

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 10 commits into
base: master
Choose a base branch
from

Conversation

kumavis
Copy link
Member

@kumavis kumavis commented Apr 24, 2025

some small improvements:

  • strict TextDecoders
  • error chaining in codecs
  • improved test coverage

related to @endo/pass-style support of "selector" (#2774)

@kumavis kumavis force-pushed the kumavis/ocapn-improvements branch from 5de9cd8 to 3801e42 Compare April 24, 2025 19:04
@kumavis kumavis changed the title Kumavis/ocapn improvements OCapN: improved error messages and testing Apr 24, 2025
@kumavis kumavis requested a review from Copilot April 24, 2025 19:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves error messages and testing support across the codebase by adding error wrapping (with nested causes) and stricter decorator-based validations, as well as expanding test coverage for various codecs and passable values. Key changes include:

  • Wrapping codec read/write methods with detailed error messages.
  • Updating test expectations to use a new throws utility and a less-strict TextDecoder for fuzz tests.
  • Renaming and prefixing codec identifiers for clarity and consistency.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/ocapn/test/syrup/* Updated tests to use a non-fatal TextDecoder for fuzz descriptor and standardized error expectations via throws utility
packages/ocapn/src/syrup/* Refactored codec implementations with error wrapping and added codec name parameters
packages/ocapn/src/codecs/* Improved error chaining, renamed codecs with consistent prefixes, and updated union codec implementations
packages/ocapn/src/syrup/buffer-reader.js Fixed a formatting bug in an error message
packages/ocapn/test/_table.js & _syrup_util.js Adjusted test table entries and moved utility functions for consistency
Comments suppressed due to low confidence (2)

packages/ocapn/src/syrup/buffer-reader.js:110

  • The error message now includes a closing parenthesis, which fixes the previous formatting issue. Verify that all similar error messages follow this corrected punctuation for consistency.
        `End of data reached (data length = ${state.length}, asked index ${index})`

packages/ocapn/test/syrup/_table.js:13

  • There is a duplicate table entry with syrup '1-' and value -1n. Confirm whether this duplication is intentional or if the redundant entry should be removed.
    { syrup: '1-', value: -1n },

@kumavis kumavis marked this pull request as ready for review April 24, 2025 19:08
@kumavis
Copy link
Member Author

kumavis commented Apr 25, 2025

@erights in order to avoid blocking this PR on @endo/pass-style Selector support, i have added a file to provide the minimal functionality needed from @endo/pass-style for this early implementation of OCapN (currently focused on message parsing). After Selector support is added to @endo/pass-style this file will be easily replaced with the methods of the same name provided by @endo/pass-style

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.

3 participants