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.
Summary
In
gateway/gateway-controller/pkg/policyxds/event_channel_translator.go, thebuildEventChannelResourceForWebBrokerfunction initializes API-level and channel-level policy slices (apiOnConnectionInit,apiOnProduce,apiOnConsume, and their channel-level equivalents) asnilrather than empty slices ([]interface{}{}). When no policies are configured, these nil slices are serialized asnullin 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, andpolicies.on_consumefields.Fix
Initialize the policy slice variables to empty slices instead of nil:
References
Requested by @senthuran16.