fix(server-runtime): preserve explicit empty route destinations (#1324)

---------

Co-authored-by: Neko <neko@ayaka.moe>
Co-authored-by-agent: Sisyphus <clio-agent@sisyphuslabs.ai>
Co-authored-by-agent: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Ryanba
2026-03-15 01:58:17 +08:00
committed by GitHub
co-authored by Neko
parent aac7a31599
commit c276bcc24d
2 changed files with 17 additions and 1 deletions
@@ -93,6 +93,22 @@ describe('route middleware', () => {
expect(collectDestinations(event)).toEqual(['label:env=prod'])
})
it('treats an explicit empty route destination list as the override', () => {
const event = createSparkNotifyEvent({
data: {
id: 'evt-override',
eventId: 'spark-override',
kind: 'ping',
urgency: 'soon',
headline: 'hello',
destinations: ['module:character'],
},
route: { destinations: [] },
})
expect(collectDestinations(event)).toEqual([])
})
it('matches destinations by label selector', () => {
const peer = createPeer({
id: 'peer-2',
@@ -79,7 +79,7 @@ export function createPolicyMiddleware(policy: RoutingPolicy): RouteMiddleware {
}
export function collectDestinations(event: WebSocketEvent | (Omit<WebSocketEvent, 'metadata'> & Partial<Pick<WebSocketEvent, 'metadata'>>)) {
if (event.route?.destinations?.length) {
if (event.route?.destinations !== undefined) {
return event.route.destinations
}