Skip to content

fix(history): return undefined when there is no history sync notification - #48

Merged
jlucaso1 merged 1 commit into
mainfrom
fix/get-history-msg-undefined
Aug 10, 2026
Merged

fix(history): return undefined when there is no history sync notification#48
jlucaso1 merged 1 commit into
mainfrom
fix/get-history-msg-undefined

Conversation

@jlucaso1

@jlucaso1 jlucaso1 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

getHistoryMsg threw a Boom 400 for any message that is not a history sync — which is most messages.

That breaks the shape a drop-in caller writes:

const h = getHistoryMsg(msg)
if (!h) return   // never reached: the line above already threw

Upstream returns undefined here. Absent is the ordinary case for this helper, not an error condition: every message that is not a history sync takes that path.

Change

Returns undefined, and the return type says | undefined so a caller who ignores it gets a type error rather than a runtime one. The Boom import is dropped along with the throw — it was the only use in the file.

The compatibility test asserted the throw; it now asserts the value, and covers two cases it did not before: a message with no content at all, and a missing argument.

assert.equal(getHistoryMsg({ conversation: 'not a history sync' }), undefined)
assert.equal(getHistoryMsg({}), undefined)
assert.equal(getHistoryMsg(undefined as never), undefined)

Registry

get-history-msg-throws-instead-of-undefined is deleted. After the change the deep pure:getHistoryMsg target runs 5001 inputs with 0 findings and 0 excused, so the entry excuses nothing and an allowlist that outlives its divergence is how the same bug comes back. Open findings 22 → 21.

Breaking change

Callers who relied on the throw to signal "not a history sync" — via try/catch — stop seeing it. That behaviour was the defect, and no caller inside this repository depended on it: getHistoryMsg has no internal call sites, only the export and its test.

Validation

tsc --noEmit, oxlint, oxfmt --check clean. npm test 1182 pass / 0 fail. npm run fuzz 185 pass / 0 fail.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RvtvVVWQs8AeBqSzS1JpCg


Generated by Claude Code


Summary by cubic

Return undefined from getHistoryMsg when a message has no history-sync notification, matching upstream and preventing crashes in common code paths. This fixes the drop-in pattern where callers check for absence instead of handling exceptions.

  • Bug Fixes

    • getHistoryMsg returns undefined instead of throwing for non-history messages.
    • Removed Boom usage and updated tests (added no-content and missing-arg cases).
    • Deleted the obsolete divergence registry entry.
  • Migration

    • If you relied on an exception to signal “not a history sync,” replace try/catch with an undefined check.

Written for commit cb11209. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Updated history message handling to return no result for messages without history data instead of raising an error.
    • Preserved normalization for messages containing valid history notifications.
  • Tests

    • Updated compatibility checks to cover missing, empty, and undefined message inputs.

…tion

`getHistoryMsg` threw a Boom 400 for any message that is not a history
sync — which is most messages. That breaks the shape a drop-in caller
writes: `const h = getHistoryMsg(msg); if (!h) return` crashes instead of
returning, and the caller has to know to wrap it.

Absent is the ordinary case here, not an error, so it returns undefined
and the return type says so. The compatibility test asserted the throw;
it now asserts the value, and covers a message with no content and a
missing argument as well.

The registry entry that documented this is deleted — the deep target runs
5001 inputs with 0 findings and 0 excused after the change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RvtvVVWQs8AeBqSzS1JpCg
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: edefc8e3-d86c-46c6-87fa-164d575f339d

📥 Commits

Reviewing files that changed from the base of the PR and between a7ffb68 and cb11209.

📒 Files selected for processing (3)
  • src/Utils/process-history-message.ts
  • src/__fuzz__/harness/divergence.ts
  • src/__tests__/public-helpers-compatibility.test.ts
💤 Files with no reviewable changes (1)
  • src/fuzz/harness/divergence.ts

📝 Walkthrough

Walkthrough

getHistoryMsg now returns undefined for messages without history-sync notifications. The public compatibility test covers these inputs, and the fuzz divergence allowlist entry is removed.

Changes

History message behavior

Layer / File(s) Summary
History message contract and validation
src/Utils/process-history-message.ts, src/__tests__/public-helpers-compatibility.test.ts, src/__fuzz__/harness/divergence.ts
getHistoryMsg returns a normalized notification when present and undefined when absent. Compatibility tests cover non-history messages, empty objects, and undefined. The obsolete fuzz divergence entry is removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A rabbit found a message bare,
No history notification there.
“Return undefined,” said the hare,
The tests now check the answer fair.
No Boom hops through the codebase air.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: returning undefined when no history sync notification exists.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jlucaso1
jlucaso1 merged commit bddb2bf into main Aug 10, 2026
6 checks passed
@jlucaso1
jlucaso1 deleted the fix/get-history-msg-undefined branch September 9, 2026 23:31
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