Skip to content

fix(assistant): normalize requestId and add input guards in AgentStreamRequestRegistry - #1920

Open
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1919-agent-stream-registry-normalization
Open

fix(assistant): normalize requestId and add input guards in AgentStreamRequestRegistry#1920
hsusul wants to merge 1 commit into
OpenWhispr:mainfrom
hsusul:fix/1919-agent-stream-registry-normalization

Conversation

@hsusul

@hsusul hsusul commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #1919

Problem

In src/helpers/agentStreamRequestRegistry.js:

  • begin(senderId, requestId) validated that requestId.trim() was non-empty, but stored the untrimmed string. If a request was registered with surrounding whitespace and cancelled without it (or vice versa), the controller lookup missed and the active stream failed to abort.
  • cancel, complete, and cancelSender did not guard against invalid types (e.g. non-integer senderId or non-string requestId).

Solution

  • Normalized requestId with .trim() consistently across begin, cancel, and complete.
  • Added input type guards for senderId and requestId across registry methods.
  • Added unit tests in test/helpers/agentStreamRequestRegistry.test.js.

Verification

  • node --test test/helpers/agentStreamRequestRegistry.test.js (passes, 7/7 tests)
  • npm run typecheck (passes, 0 errors)
  • npm run lint (passes, 0 errors)
  • npm run i18n:check (passes)
  • npm run build:renderer (passes)
  • git diff --check (clean)

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.

AgentStreamRequestRegistry requestId whitespace mismatch and missing type safety in cancel/complete methods

1 participant