wso2 / wso2/api-platform

Fix nil-vs-empty-array inconsistency in buildEventChannelResourceForWebBroker policy lists

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

@senthuran16 is already working on this.

Since May 14, 2026.

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

Description

Summary

In gateway/gateway-controller/pkg/policyxds/event_channel_translator.go, the buildEventChannelResourceForWebBroker function initializes API-level and channel-level policy slices (apiOnConnectionInit, apiOnProduce, apiOnConsume, and their channel-level equivalents) as nil rather than empty slices ([]interface{}{}). When no policies are configured, these nil slices are serialized as null in the EventChannelConfig xDS resource, whereas the equivalent WebSub translator (buildEventChannelResourceForWebSub) correctly emits empty arrays for the same case.

This inconsistency in the wire format can cause unexpected behavior in the event gateway runtime when it parses policies.on_connection_init, policies.on_produce, and policies.on_consume fields.

Fix

Initialize the policy slice variables to empty slices instead of nil:

// API-level
apiOnConnectionInit := []interface{}{}
apiOnProduce := []interface{}{}
apiOnConsume := []interface{}{}

// Channel-level (inside the channels loop)
channelOnConnectionInit := []interface{}{}
channelOnProduce := []interface{}{}
channelOnConsume := []interface{}{}

References

Requested 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.