:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(notebooks): guard non-array node children in side column (#88689)
posthog[bot]d9626ce5cc72
diff --git a/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts b/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.tsindex d3a4dbf54302..1e5da06f6e6c 100644--- a/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts+++ b/frontend/src/scenes/notebooks/Nodes/notebookNodeLogic.ts@@ -1408,7 +1408,11 @@ export const notebookNodeLogic = kea<notebookNodeLogicType>([(editableTitle ? nodeAttributes.title : null) || titlePlaceholder,],// TODO: Fix the typing of nodeAttributes- children: [(s) => [s.nodeAttributes], (nodeAttributes): NotebookNodeResource[] => nodeAttributes.children],+ children: [+ (s) => [s.nodeAttributes],+ (nodeAttributes): NotebookNodeResource[] =>+ Array.isArray(nodeAttributes.children) ? nodeAttributes.children : [],+ ],exportedGlobals: [(s) => [s.nodeAttributes],diff --git a/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsx b/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsxindex d465baf4b41d..9bc9e876a00c 100644--- a/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsx+++ b/frontend/src/scenes/notebooks/Notebook/NotebookColumnRight.tsx@@ -40,7 +40,10 @@ const Widgets = ({ nodeLogic }: { nodeLogic: BuiltLogic<notebookNodeLogicType> }// TODO: IMPORTANT: The nodeId is basically now required, so we should be checking that in the logic// otherwise we end up in horrible re-rendering loops- children.forEach((content) => {+ // A node's children attribute can be a non-array value, so guard before iterating.+ const childNodes = Array.isArray(children) ? children : []++ childNodes.forEach((content) => {if (!content.attrs.nodeId) {content.attrs.nodeId = uuid()}@@ -48,7 +51,7 @@ const Widgets = ({ nodeLogic }: { nodeLogic: BuiltLogic<notebookNodeLogicType> }return (<>- {children?.map((child) => (+ {childNodes.map((child) => (<NotebookNodeChildRenderer key={child.attrs.nodeId} content={child} />))}</>diff --git a/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookLogic.tsindex bab8e3c4e2ac..9656c5d92377 100644--- a/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts+++ b/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts@@ -1388,7 +1388,9 @@ export const notebookLogic = kea<notebookLogicType>([// oxlint-disable-next-line @typescript-eslint/no-unused-vars(nodeLogics: Record<string, BuiltLogic<notebookNodeLogicType>>, _content: JSONContent) => {// NOTE: _content is not but is needed to retrigger as it could mean the children have changed- return Object.values(nodeLogics).filter((nodeLogic) => nodeLogic.props.attributes?.children)+ return Object.values(nodeLogics).filter((nodeLogic) =>+ Array.isArray(nodeLogic.props.attributes?.children)+ )},],