From 8bdeea258d3dc92d026a0c655da1ba8321a48afc Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Tue, 1 Jul 2025 13:42:01 +0200 Subject: [PATCH] When flattening don't treat `null` as an object Despite our best efforts we do allow `null` as a value in e.g. object metrics to be sent. That previously crashed the frontend as it tried to dive into `null` as if it was an object. It's not, despite everything `typeof null` wants to tell you. We handle that case explicitly now and just render `null` values as ... nothing. Fixes #233 --- src/lib/flattenJson.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/flattenJson.js b/src/lib/flattenJson.js index 6ae4411..a1e7a13 100644 --- a/src/lib/flattenJson.js +++ b/src/lib/flattenJson.js @@ -50,7 +50,7 @@ export const flattenJson = (json) => { flatten(value, `${name} [${i.toString()}].`); i += 1; }); - } else if (typeof valueToFlatten === 'object') { + } else if (valueToFlatten != null && typeof valueToFlatten === 'object') { Object.keys(valueToFlatten).forEach((key) => { flatten(valueToFlatten[key], name + key + '.'); });