-
-
Notifications
You must be signed in to change notification settings - Fork 396
Standardize and enhance error handling across hooks and worker service #295
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added detailed error logging in context-hook, new-hook, save-hook, and summary-hook to capture status, project, port, and relevant session information on failures. - Improved error messages thrown in save-hook and summary-hook to include specific context about the failure.
- Updated SessionSearch and SessionStore classes to replace console.error with console.log for migration-related messages. - Added notes in the documentation to clarify the use of console.log for migration messages due to the unavailability of the structured logger during constructor execution.
- Updated SDKAgent to use direct defaults instead of happy_path_error__with_fallback for non-critical fields such as last_user_message, last_assistant_message, title, filesRead, filesModified, concepts, and summary.request. - Enhanced silent-debug documentation to clarify appropriate use cases for happy_path_error__with_fallback, emphasizing its role in handling unexpected null/undefined values while discouraging its use for nullable fields with valid defaults.
…rrors
Fixes false "Missing cwd" and "Missing transcript_path" errors that were
flooding silent.log even when values were present.
Root cause: happy_path_error__with_fallback was being called unconditionally
instead of only when the value was actually missing.
Pattern changed from:
value: happy_path_error__with_fallback('Missing', {}, value || '')
To correct usage:
value: value || happy_path_error__with_fallback('Missing', {}, '')
Fixed in:
- src/hooks/save-hook.ts (PostToolUse hook)
- src/hooks/summary-hook.ts (Stop hook)
- src/services/worker/http/routes/SessionRoutes.ts (2 instances)
Impact: Eliminates false error noise, making actual errors visible.
Addresses issue #260 - users were seeing "Missing cwd" errors despite
Claude Code correctly passing all required fields.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
- Improved error messages in SessionStore to include project context when fetching boundary observations and timestamps. - Updated ChromaSync error handling to provide more informative messages regarding client initialization failures, including the project context. - Enhanced error logging in WorkerService to include the package path when reading version fails. - Added detailed error logging in worker-utils to capture expected and running versions during health checks. - Extended WorkerErrorMessageOptions to include actualError for more informative restart instructions.
- Introduced a new error handler `handleFetchError` in `shared/error-handler.ts` to standardize logging and user-facing error messages for fetch failures across hooks. - Updated `context-hook.ts`, `new-hook.ts`, `save-hook.ts`, and `summary-hook.ts` to utilize the new error handler, improving consistency and maintainability. - Removed redundant imports and error handling logic related to worker restart instructions from the hooks.
Resolved conflicts by rebuilding plugin scripts from updated source. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Code Review for PR 295This is an excellent, comprehensive improvement to error handling across the codebase. Strengths
Areas for Improvement
Security & Performance
Checklist Summary
Final VerdictAPPROVED This is production-ready and significantly improves codebase reliability. The standardized error handling and comprehensive tests provide excellent regression protection. Minor suggestions above are optimizations, not blockers. This PR can be merged with confidence. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR comprehensively improves error handling quality across the claude-mem codebase:
cwdfield - observations not being saved #260) wherehappy_path_error__with_fallbackmisuse caused spurious errorsKey Changes
Hook Error Standardization
src/hooks/shared/error-handler.tswithhandleFetchError()andhandleWorkerError()utilitiesChromaSync Error Messages
Worker Service Improvements
Bug Fixes
cwdfield - observations not being saved #260: Fixedhappy_path_error__with_fallbackmisuse in save-hook causing false "Missing cwd" errorsTest Coverage
tests/error-handling/hook-error-logging.test.ts- 12 tests validating hook error handler behaviortests/services/chroma-sync-errors.test.ts- Tests for ChromaSync error message consistencytests/integration/hook-execution-environments.test.ts- Tests for Bun PATH resolution across shellsdocs/context/TEST_AUDIT_2025-12-13.md- Comprehensive audit report documenting coverage improvementsTesting
All 52 existing tests continue to pass. Added 12+ new tests specifically for error handling scenarios.
npm testFiles Changed
27 files changed: 1,435 additions, 200 deletions
Core changes:
src/hooks/shared/error-handler.ts(new)Related Issues
Fixes #260 - False "Missing cwd" errors from happy_path_error misuse
🤖 Generated with Claude Code