From e59d2dd8dfbd948cbadbf56f4c311d7b29fe1feb Mon Sep 17 00:00:00 2001 From: AustinMroz Date: Mon, 13 Oct 2025 11:52:03 -0700 Subject: [PATCH] Use type check instead of cast (#6041) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under some infrequent circumstances, `audioWidget.value` is not a string. Presumably if a workflow is loaded with a saved file choice that does not exist and the value is set to undefined instead. Instead of a cast, a proper type guard is used and the widget is not updated if the new value is not a string. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6041-Use-type-check-instead-of-cast-28b6d73d365081249353f4f905769f89) by [Unito](https://www.unito.io) --- src/extensions/core/uploadAudio.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/extensions/core/uploadAudio.ts b/src/extensions/core/uploadAudio.ts index bde5af6c1..d6bec005a 100644 --- a/src/extensions/core/uploadAudio.ts +++ b/src/extensions/core/uploadAudio.ts @@ -178,8 +178,9 @@ app.registerExtension({ audioUIWidget.options.canvasOnly = true const onAudioWidgetUpdate = () => { + if (typeof audioWidget.value !== 'string') return audioUIWidget.element.src = api.apiURL( - getResourceURL(...splitFilePath(audioWidget.value as string)) + getResourceURL(...splitFilePath(audioWidget.value)) ) } // Initially load default audio file to audioUIWidget.