TomFrankly / pipedream-notion-voice-notes

Take notes with your voice and send them to Notion
94 stars 49 forks source link

Type Error with the sendAdditionalInfotoNotion function around line 1800 #49

Closed koorbs closed 7 months ago

koorbs commented 7 months ago

TypeError Cannot read properties of null (reading '0') DETAILS at Object.run (file:///tmp/pdg/dist/code/4cf355a52ab0f9c275ba953eea42492276c4b796f961fdffefa87942b1ced4df/code/Notion-Voice-Notes.mjs:1848:49) at null.executeComponent (/var/task/launch_worker.js:267:22) at MessagePort.messageHandler (/var/task/launch_worker.js:764:28) Anybody got any suggestions on wether this is a me problem or a code problem and how I might fix this if it's a me problem? :)

TomFrankly commented 7 months ago

Hi @koorbs!

Can you paste the contents of your Logs tab? I think we'll need those to debug this :)

koorbs commented 7 months ago

Hey cheers for the quick reply and thanks for the help @TomFrankly Here are the logs, though the code didn't log much before the error occurred. 24/11/2023, 20:15:08 Checking that file is under 300mb... 24/11/2023, 20:15:08 File size is approximately 52.3mb. 24/11/2023, 20:15:08 File is under the size limit. Continuing... 24/11/2023, 20:15:08 Checking if the user set languages... 24/11/2023, 20:15:08 User set transcript language to de. 24/11/2023, 20:15:08 User set summary language to de.

TomFrankly commented 7 months ago

@koorbs thanks for that context! This is leading me to believe the file name might be the culprit. Can you let me know what the file name is for the audio file, and if it contains non-standard-English characters?

Here's a sample of the Logs from my last successful run (I almost never have failed runs, so it's tough to debug these)

11/20/2023, 2:48:47 PM
Checking that file is under 300mb...

11/20/2023, 2:48:47 PM
File size is approximately 0.6mb.

11/20/2023, 2:48:47 PM
File is under the size limit. Continuing...

11/20/2023, 2:48:47 PM
Checking if the user set languages...

11/20/2023, 2:48:47 PM
No language set. Whisper will attempt to detect the language.

11/20/2023, 2:48:47 PM
Downloaded file to tmp storage:

11/20/2023, 2:48:47 PM
{ path: '/tmp/dv-2023-11-20-144832.mp3', mime: '.mp3' }

11/20/2023, 2:48:47 PM
Successfully got duration: 63 seconds

11/20/2023, 2:48:47 PM
Chunking file: /tmp/dv-2023-11-20-144832.mp3

11/20/2023, 2:48:47 PM
Chunks created successfully. Transcribing chunks: chunk-000.mp3

11/20/2023, 2:48:47 PM
Transcribing file: chunk-000.mp3

One other question: Are you using Dropbox, or Google Drive/OneDrive? With Dropbox, the file is downloaded to temp storage within this action. With the other two, it's downloaded in prior steps. Knowing which you're using will help to narrow this down!

koorbs commented 7 months ago

The Title of the File is: "Aerztliche Denkfehler Vom Bias zur Fehldiagnose", I'm using Google Drive and the error occurs in the third step after the file was successfully downloaded. I've left the Previous Step Data set to {{steps}} so that shouldn't be an issue. The Workflow used to work but I haven't used it in about a month and then I updated it and now the error is thrown. I've used different Files, but the error is always thrown. I've set left Note Duration, Cost and Tag free since I wasn't totally sure what to enter and it had been free before. The Model is set to GPT-4, Summary Density to 2400, Verbosity to High, Summary and Transcript Languages are set to German since the audios for this workflow are in German, the Model Temperature is set to 0.2 and the Audio File Chunk Size is set to 20mb. Thanks again so much for your help @TomFrankly and thanks for introducing me to Pipedream, learning to code and automating Flashcard writing and transcribing is a lot of help in Med School :)

TomFrankly commented 7 months ago

@koorbs ok, I just set up a brand new copy of the workflow and matched your settings exactly. My audio file was actually in English and was an mp3, but I set the file name to Aerztliche Denkfehler Vom Bias zur Fehldiagnose.

The first time I tested, I got the error. But then I went up and re-tested the Google Drive step, then re-tested the final step.

This time it worked perfectly.

Did you encounter this issue while testing the workflow, or while running it normally? In my case, it seems that the issue is that the file had been cleared from temp storage before my notion_voice_notes action could be run. But this type of thing never happens during normal, automated runs since everything runs so fast.

koorbs commented 7 months ago

@TomFrankly I tried running the full workflow, but the error still occurs

Message: Cannot read properties of null (reading '0') Total Duration: 6,342 ms Compute Time: 6,055 ms Execution Start: 2023-11-25T21:09:10.687Z Execution End: 2023-11-25T21:09:17.029Z Steps Executed: 2 / 2 Credits: 5 Version: 49 (d_evs8aRE5) TypeError Cannot read properties of null (reading '0') DETAILS at Object.run (file:///tmp/pdg/dist/code/da0675b74e78f05c34811117c0816207386b9ed914b78651fd4d747c1602227f/code/Notion-Voice-Notes.mjs:1890:49) at null.executeComponent (/var/task/launch_worker.js:267:22) at MessagePort.messageHandler (/var/task/launch_worker.js:764:28)

koorbs commented 7 months ago

steps.google_drive_download {2} $summary Successfully downloaded the file, "Aerztliche Denkfehler Vom Bias zur Fehldiagnose" $return_value {2} name: Aerztliche Denkfehler Vom Bias zur Fehldiagnose mimeType: audio/mpeg This is the export from the previous Drive Step, so there shouldn't be any issue with the file being accessed, but the file Info is apparently not passed as an array so it reads 0 and then throws the error

TomFrankly commented 7 months ago

@koorbs ah, I see the issue. Your "name" property doesn't include the mimetype.

Here you can see that mine does:

CleanShot 2023-11-25 at 15 48 01@2x

It's not an array issue; it's that the code is using the String.prototype.match method to get the mimetype from the name string.

You can see how it's supposed to work here: https://regex101.com/r/rtLrSx/1

Because yours is missing the mimetype in the name string, the [0] index doesn't exist since the match method returns nothing.

This is quite odd, as the filename should have that mimetype right in it:

CleanShot 2023-11-25 at 15 51 54@2x

Are you somehow uploading audio files to Google Drive that do not have a file extension? I don't see how that would be possible, but that's the actual issue here.

koorbs commented 7 months ago

@TomFrankly Damm just realised that uploading the file from the files app to the drive somehow removes the file extension, but dragging it into the drive doesn't and the workflow then works. Thanks soo much for the help in solving this and learned something new now :)

TomFrankly commented 7 months ago

@koorbs oh that's interesting! I didn't know that either. What device are you using with the Files app? An iOS device?