Skip to content

Conversation

@nicoloboschi
Copy link
Collaborator

Summary

  • Adds a validateResponse helper method that checks for API errors
  • Applies error checking to all API methods that previously returned response.data! without validation
  • Now all methods throw descriptive errors when API calls fail instead of silently returning undefined

Problem

Most methods in the TypeScript client were returning response.data! without checking if the response was successful. When the API was unreachable or returned an error, these methods would silently return undefined instead of throwing an error.

This was discovered when running load tests against a non-existent server - the tests showed 100% success rate because retain and reflect never threw errors.

Changes

Methods updated:

  • retain
  • retainBatch
  • recall (already had error checking, now uses the shared helper)
  • reflect
  • listMemories
  • createBank
  • getBankProfile

Test plan

  • All existing tests pass (npm test)
  • TypeScript compiles without errors (npm run build)

Previously, most methods in HindsightClient would silently return
undefined when API calls failed (e.g., connection refused). Only
the `recall` method had proper error checking.

This change adds a `validateResponse` helper method and applies it
consistently to all API methods:
- retain
- retainBatch
- recall
- reflect
- listMemories
- createBank
- getBankProfile

Now all methods properly throw an error with details when the API
request fails, instead of returning undefined.
@nicoloboschi nicoloboschi merged commit 0d0abaa into main Jan 9, 2026
23 of 25 checks passed
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