Skip to content

fix: preserve provider errors in user profile learning - #267

Merged
tickernelz merged 1 commit into
mainfrom
fix/issue-265-profile-learning-errors
Aug 25, 2026
Merged

fix: preserve provider errors in user profile learning#267
tickernelz merged 1 commit into
mainfrom
fix/issue-265-profile-learning-errors

Conversation

@lindixu6-hash

Copy link
Copy Markdown
Collaborator

Summary

When the opencode provider path in analyzeUserProfile() throws and no manual external API fallback (memoryModel/memoryApiUrl) is configured, the original provider error was silently replaced by a generic "External API not configured for user memory learning" message. This made debugging provider failures (e.g. unsupported tool_choice in thinking mode) impossible from logs.

Changes

  • Store the opencode provider error in a local variable (same pattern as fix: preserve opencode auto-capture errors #258 for auto-capture).
  • When no manual fallback is configured, rethrow the original error instead of the generic message.
  • When a manual fallback IS configured, behavior is unchanged: the error is logged and the fallback runs.
  • Added regression test user-profile-learning-error.test.ts that mocks a throwing opencode provider with no fallback and verifies the surfaced error contains the real root cause.

Testing

  • bun test tests/user-profile-learning-error.test.ts — 1/1 pass
  • tsc --noEmit clean

Closes #265

When the opencode provider path throws and no manual external API
fallback is configured, surface the original provider error instead
of masking it with a generic 'External API not configured' message.

This mirrors the same fix applied to auto-capture in #258.

Closes #265
@lindixu6-hash

Copy link
Copy Markdown
Collaborator Author

Reviewer quick guide: This is a 3-line source change mirroring the exact pattern already merged in #258 (auto-capture error preservation, reviewed by @NaNomicon).

Source diff (src/services/user-memory-learning.ts):

  1. Declare opencodeProviderError before the try block (line 635)
  2. Capture the caught error (line 698)
  3. Rethrow it when no manual fallback exists (lines 706-708)

Test: tests/user-profile-learning-error.test.ts uses the same subprocess mock pattern as #258's test — mocks a throwing generateStructuredOutput, runs performUserProfileLearning, and asserts the surfaced error contains the real provider message ("Thinking mode does not support") rather than the generic "External API not configured".

Risk: Minimal — only changes the error message surfaced to users when their primary provider is broken and no fallback exists. The happy path and fallback path are untouched.

@tickernelz
tickernelz merged commit 89c9e7e into main Aug 25, 2026
7 checks passed
@tickernelz
tickernelz deleted the fix/issue-265-profile-learning-errors branch August 25, 2026 03:57
phil-lipp pushed a commit to phil-lipp/opencode-mem that referenced this pull request Aug 25, 2026
…or propagation

- pin bun-types to 1.3.14 via overrides: @types/bun 1.4.0 narrows the
  NodeJS.Process event surface (memoryPressure-only), which breaks
  process.on(SIGINT/SIGTERM/beforeExit/exit) typecheck on main
- rethrow in performUserProfileLearning after logging so provider errors
  keep propagating per tickernelz#267/tickernelz#265 instead of being silently swallowed
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.

fix: preserve provider errors in user profile learning

2 participants