From f8abad232d67eb63a0eec107f867c4dfcee6c427 Mon Sep 17 00:00:00 2001 From: Joel Takvorian Date: Wed, 13 Nov 2024 11:21:32 +0100 Subject: [PATCH] NETOBSERV-1958: fix CSV export (#643) Do not stringify undefined fields as they end up == "undefined" --- web/src/model/__tests__/export-query.spec.ts | 1 + web/src/model/export-query.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/src/model/__tests__/export-query.spec.ts b/web/src/model/__tests__/export-query.spec.ts index 4d60df1aa..53f21a8b6 100644 --- a/web/src/model/__tests__/export-query.spec.ts +++ b/web/src/model/__tests__/export-query.spec.ts @@ -5,6 +5,7 @@ describe('buildExportQuery', () => { const query = buildExportQuery({ filters: 'SrcK8S_Name%3Dtest1%2Ctest2', recordType: 'flowLog', + namespace: undefined, dataSource: 'auto', packetLoss: 'all', limit: 500, diff --git a/web/src/model/export-query.ts b/web/src/model/export-query.ts index ccac17488..5b0bfb047 100644 --- a/web/src/model/export-query.ts +++ b/web/src/model/export-query.ts @@ -1,3 +1,4 @@ +import * as _ from 'lodash'; import { FlowQuery } from './flow-query'; export const buildExportQuery = (flowQuery: FlowQuery, columns?: string[]) => { @@ -11,5 +12,6 @@ export const buildExportQuery = (flowQuery: FlowQuery, columns?: string[]) => { if (columns) { query.columns = String(columns); } - return new URLSearchParams(query).toString(); + const omitEmpty = _.omitBy(query, a => a === undefined); + return new URLSearchParams(omitEmpty).toString(); };