From 962e0e50b9eeb376e9027e90d2bb712d708bbfd6 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Fri, 4 Aug 2023 15:03:13 -0400 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 (#758) (#848) (cherry picked from commit a0a62af9527aaa87f7057ebf50ceec95b395b634) Signed-off-by: YANGDB Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] (cherry picked from commit 711a71fcb348713ef6a02feea968a3a78d1b5d57) --- auto_sync_commit_metadata.json | 4 ++-- server/adaptors/integrations/repository/integration.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/auto_sync_commit_metadata.json b/auto_sync_commit_metadata.json index 1c4fc1b8b..a6acfc2e3 100644 --- a/auto_sync_commit_metadata.json +++ b/auto_sync_commit_metadata.json @@ -1,4 +1,4 @@ { - "last_github_commit": "1342df021fca66d1187b2fb84e01c61c50ab469a", - "last_gitfarm_commit": "5a804795b2be1b07610a02ffd52b198fcc985e29" + "last_github_commit": "711a71fcb348713ef6a02feea968a3a78d1b5d57", + "last_gitfarm_commit": "e564e78330a8e9876e41c834275e9ef784a1b192" } \ No newline at end of file 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) {