diff --git a/frontend/src/features/platform-broadcast/services/broadcast-http.service.ts b/frontend/src/features/platform-broadcast/services/broadcast-http.service.ts index 438bea2c3..72a0fc830 100644 --- a/frontend/src/features/platform-broadcast/services/broadcast-http.service.ts +++ b/frontend/src/features/platform-broadcast/services/broadcast-http.service.ts @@ -32,12 +32,17 @@ function withSelector(selector: BulkSelector, resource: T) { return { selector, ...resource } } +// Go's nil slices marshal to JSON null; normalize so consumers can safely read `.length`. +function normalize(r: BulkResult | null | undefined): BulkResult { + return { succeeded: r?.succeeded ?? [], failed: r?.failed ?? [] } +} + async function post( path: string, selector: BulkSelector, resource: Resource, ): Promise { - return api.post(path, withSelector(selector, resource)) + return normalize(await api.post(path, withSelector(selector, resource))) } /** Send `resource` to every selected tenant against `path` (a full `/platform/**\/bulk/**` route). */ @@ -108,5 +113,5 @@ export async function broadcastBrandingAsset( const form = new FormData() form.append('file', file) form.append('selector', JSON.stringify(selector)) - return api.post(BULK_PATHS.branding.uploadAsset(slot), form) + return normalize(await api.post(BULK_PATHS.branding.uploadAsset(slot), form)) }