Skip to content

: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.

fix(notebooks): don't show error toast when JSON file selection is cancelled (#61362)

Andre de Vries314058bc47fc
diff --git a/frontend/src/scenes/notebooks/NotebookCanvasScene.tsx b/frontend/src/scenes/notebooks/NotebookCanvasScene.tsx
index 0fc087d6933f..4c5a68c75b16 100644
--- a/frontend/src/scenes/notebooks/NotebookCanvasScene.tsx
+++ b/frontend/src/scenes/notebooks/NotebookCanvasScene.tsx
@@ -61,8 +61,11 @@ export function NotebookCanvas(): JSX.Element {
contentType: 'application/json',
multiple: false,
})
- .then((files) => getTextFromFile(files[0]))
- .then((text) => {
+ .then(async (files) => {
+ if (!files.length) {
+ return
+ }
+ const text = await getTextFromFile(files[0])
const data = JSON.parse(text)
if (data.type !== 'doc') {
throw new Error('Not a notebook')
diff --git a/frontend/src/scenes/notebooks/NotebooksScene.tsx b/frontend/src/scenes/notebooks/NotebooksScene.tsx
index 16f1391e8d88..144e01b629a3 100644
--- a/frontend/src/scenes/notebooks/NotebooksScene.tsx
+++ b/frontend/src/scenes/notebooks/NotebooksScene.tsx
@@ -44,8 +44,11 @@ export function NotebooksScene(): JSX.Element {
contentType: 'application/json',
multiple: false,
})
- .then((files) => getTextFromFile(files[0]))
- .then((text) => {
+ .then(async (files) => {
+ if (!files.length) {
+ return
+ }
+ const text = await getTextFromFile(files[0])
const data = JSON.parse(text)
if (data.type !== 'doc') {
throw new Error('Not a notebook')