From a6704a6235053c36ae38831e7459a1bf245dcf9a Mon Sep 17 00:00:00 2001 From: YANGDB Date: Wed, 26 Jul 2023 14:29:16 -0700 Subject: [PATCH] fix integration json loading parser so that it will trim unneeded empty spaces from the ndjson file and match the existing behavior of the savedObject import dashboard that works even when empty spaces appear in the ndjson file Signed-off-by: YANGDB --- server/adaptors/integrations/repository/integration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/adaptors/integrations/repository/integration.ts b/server/adaptors/integrations/repository/integration.ts index 24388eff1..fe9ddd0ef 100644 --- a/server/adaptors/integrations/repository/integration.ts +++ b/server/adaptors/integrations/repository/integration.ts @@ -211,7 +211,7 @@ export class Integration { ); try { const ndjson = await fs.readFile(sobjPath, { encoding: 'utf-8' }); - const asJson = '[' + ndjson.replace(/\n/g, ',') + ']'; + const asJson = '[' + ndjson.trim().replace(/\n/g, ',') + ']'; const parsed = JSON.parse(asJson); result.savedObjects = parsed; } catch (err: any) {