Skip to content

Conversation

@jgowdy-godaddy
Copy link
Collaborator

Summary

  • Adds function names and context to all error messages
  • Uses consistent error handling pattern
  • Makes debugging easier

Changes

  1. Add function names to all CobhanBuffer error messages
  2. Include operation context (e.g., 'CobhanBuffer::set_data_len_bytes')
  3. Add clarification about limits (e.g., '2GB limit')
  4. Fix inconsistent error handling - replaced direct napi_throw_error with NapiUtils::ThrowException

Examples

Before:

"Requested data length exceeds maximum allowable size"

After:

"CobhanBuffer::set_data_len_bytes: Requested data length exceeds maximum allowable size (2GB limit)"

Benefits

  • Easier debugging - immediately see which function threw the error
  • Clear understanding of constraints and limits
  • Consistent error handling throughout the codebase

Test plan

  • All tests pass
  • Error messages are more descriptive
  • No breaking changes

🤖 Generated with Claude Code

jgowdy-godaddy and others added 8 commits August 2, 2025 09:47
- Add RequireParameterStringWithLength to get string and length in one call
- Reduces N-API boundary crossings from 2-3 to 1 for partition ID validation
- Same functionality, better performance by eliminating duplicate GetUtf8StringLength calls
- Add RequireParameterStringWithLength to get string and length in one call
- Add optional utf8_length parameter to CobhanBufferNapi constructors and copy_from_string
- Add optional utf8_length parameter to StringToAllocationSize
- Update BeginEncryptToJson/BeginDecryptFromJson to return partition_id_length
- Reduces redundant GetUtf8StringLength calls when validating empty partition IDs
- Foundation for further optimization to eliminate all redundant string length calls
- Pass partition_id_length through all async methods to avoid redundant GetUtf8StringLength calls
- Update stack allocation cases to use pre-calculated length for StringToAllocationSize
- Reduces N-API boundary crossings from 2-3 to 1 for partition ID validation

This completes the optimization suggested in PR feedback to calculate string
length once during validation and reuse it throughout the operation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add missing await to assert_throws_async calls in multiple test functions
- Fix assert_encrypt_string to handle empty strings correctly
  (indexOf('') always returns 0, not -1)

These tests were incorrectly passing because the async assertions
were not being awaited, causing the test to complete before the
assertion could fail.

Note: Empty content encryption is actually allowed by Asherah,
so these tests pass even with the fixes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Document all remaining issues found after implementing fixes across branches:
- Integer overflow vulnerabilities in size calculations
- Stack overflow risk in SCOPED_ALLOCATE
- Buffer underflow in AllocationSizeToMaxDataSize
- Performance optimization opportunities
- Testing gaps and API design issues
- Build system improvements

This report prioritizes issues by severity and provides specific
fixes for each issue identified.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
The stack allocation via alloca() is working as designed:
- Default maximum_stack_alloc_size is 2048 bytes (reasonable)
- Users can adjust at their own risk
- This is an intentional performance optimization

Updated report to show only 3 critical issues instead of 4.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Mark issue #10 (Missing Move Semantics) as fixed and add the
add-move-optimizations branch to the list of implemented fixes.

Updated summary to show 18 remaining issues (down from 19) and
list all 7 branches with fixes.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
- Add function names to all CobhanBuffer error messages
- Include operation context (e.g., 'CobhanBuffer::set_data_len_bytes')
- Add clarification about limits (e.g., '2GB limit')
- Use consistent error handling pattern with NapiUtils::ThrowException

This makes debugging easier by clearly identifying which operation failed
and why, especially useful when errors bubble up through the stack.
@jgowdy-godaddy jgowdy-godaddy force-pushed the improve-error-context branch from 04d9333 to 5c2ccbd Compare August 3, 2025 19:36
@jgowdy-godaddy jgowdy-godaddy force-pushed the improve-error-context branch from c517e9f to cfbb8a1 Compare August 3, 2025 19:56
Force use of installed Go version (1.24.0) instead of allowing automatic
download of Go 1.24.1 which causes version mismatch errors in CI.
Prevent version conflict error when dry-running npm publish since
the package.json version is 0.0.0 but published version is 3.0.8.
The CI npm version requires a tag when the package.json version (0.0.0)
is lower than the published version (3.0.8), even for dry-run.
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.

2 participants