wso2 / wso2/api-platform

WebBrokerAPI: Guard channel reads with comma-ok pattern in WebBrokerApi receiver to prevent nil-message panics

Open
#1,959 0 comments 0 reactions 1 assignee View on GitHub

@senthuran16 is already working on this.

Since May 14, 2026.

Area/EventGateway
Dominant language
Go
Stars
71
Forks
111
Avg merge
1d 14h
Merged PRs (30d)
110

Description

Summary

In event-gateway/gateway-runtime/internal/connectors/receiver/websocket/broker_api_connector.go, the channel receives in inboundLoop (around line 406) and outboundLoop (around line 465) use the plain form (msg := <-conn.inbound / msg := <-conn.outbound). When teardown closes these channels, the receive returns a zero/nil value and subsequent dereferences (e.g., msg.Value) can panic.

Proposed Fix

Apply the comma-ok pattern to both receive sites so the loops exit cleanly when the channel is closed:

// inboundLoop
case msg, ok := <-conn.inbound:
    if !ok || msg == nil {
        return
    }

// outboundLoop
case msg, ok := <-conn.outbound:
    if !ok || msg == nil {
        return
    }

References

Raised by @senthuran16.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.