Skip to content

fix: correct multiple server-side bugs in handlers and model client#330

Open
wishhyt wants to merge 1 commit into
plandex-ai:mainfrom
wishhyt:fix/server-handler-bugs
Open

fix: correct multiple server-side bugs in handlers and model client#330
wishhyt wants to merge 1 commit into
plandex-ai:mainfrom
wishhyt:fix/server-handler-bugs

Conversation

@wishhyt

@wishhyt wishhyt commented Mar 18, 2026

Copy link
Copy Markdown

Summary

Fix 4 server-side bugs:

  • InviteUserHandler (invites.go:81-86): Two bugs in domain check: (1) compared
    pointer addresses instead of string values (org.Domain == domain where both are
    *string), making the check always fail; (2) missing return after http.Error(),
    allowing execution to continue and potentially create duplicate invites.
  • CreateChatCompletionWithInternalStream (client_stream.go:43-44): Unconditionally
    appended :nitro to OpenRouter model names without checking for existing suffixes.
    The non-streaming CreateChatCompletionStream in client.go correctly checks for
    :nitro, :free, and :floor suffixes. Added the same check to prevent invalid
    model names like model:free:nitro.
  • AddPlanConvoMessage (plan_helpers.go:178-182): Missing return after sending
    error to errCh. When Exec failed, both an error and a nil were sent (2 writes),
    but combined with the first goroutine's write (1 write), that's 3 writes to a channel
    read only 2 times — the third write blocks forever, leaking the goroutine.
  • ListPlansRunningHandler (plans_crud.go:544-549): Sort function used composite
    key PlanId + "|" + Name to look up StreamFinishedAtByBranchId map, but the map
    was keyed by branch.Id. Lookups always missed, making the sort ineffective.

Test plan

  • Verify invite domain check correctly prevents duplicate invites
  • Verify OpenRouter models with :free or :floor suffix work in streaming mode
  • Verify no goroutine leaks when plan reply count update fails
  • Verify running plans list is correctly sorted by stream status

- InviteUserHandler: fix pointer comparison of org.Domain (compared addresses
  instead of string values) and add missing return after http.Error
- client_stream.go: add suffix check before appending :nitro to OpenRouter
  model names, matching the existing check in client.go (prevents invalid
  model names like "model:free:nitro")
- plan_helpers.go: add missing return after sending error to errCh, preventing
  a second write that would block the goroutine permanently (goroutine leak)
- ListPlansRunningHandler: use branch Id for map lookups in sort function
  instead of composite key (PlanId|Name), matching the keys used when
  populating StreamFinishedAtByBranchId and StreamStartedAtByBranchId

Made-with: Cursor
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.

1 participant