[SOLVED] Extract Note null check
This discussion was created from comments split from: Welcome Testers! Download link in thread..
Post edited by ctietze on
Howdy, Stranger!
Categories
- 3K All Categories
- 152 Research & Reading
- 692 The Zettelkasten Method
- 7 Knowledge Work
- 100 Writing
- 464 Software & Gadgets
- 154 Workflows
- 730 The Archive
- 15 Plug-In Showcase
- 88 Resolved Issues
- 225 Projects Logs and Journals
- 83 Project: Zettelkasten.de
- 53 Critique my Zettel
- 171 Random
- 373 Introduce Yourselves!
Comments
Clicking 'cancel' on "new note's filename" dialog for plugin 'extract note' in b249 fails with

Reported error: The operation couldn’t be completed. (UserlandJS.JavaScriptError error 1.) 18:08:05: > . . CompletingFileNameChange(fileNameChange: State.FileNameChange(identifier: ¿Untitled?, newTitle: test cancel, cachedContent: "test cancel", uuid: E0E18D59-CB7D-4063-A24C-1E1C7ADA25DC), note: Note(fn=Filename(test cancel), "⌃(created: T(747158880.4275336), modified: T(747158883.8587186), url: file://I removed real path to file/test%20cancel.md", content="test cancel")) 18:08:05: > . . . Thunk<AppState>(body: (Function)) 18:08:05: ⎌ register undo of WorkspaceTargeted<CompletingNoteRenaming> using WorkspaceTargeted<RenamingNote> with redo WorkspaceTargeted<RenamingNote> 18:08:05: > . . . . CompletingNoteRenaming(oldIdentifier:¿Untitled?, newIdentifier: ¿test cancel?) @ W:1 18:08:05: > . . . . . RenamingNoteInHistory(oldNoteID: ¿Untitled?, newNoteID: ¿test cancel?) @ W:1 18:08:05: > . . . . . RenamingNoteInWorkspace(oldIdentifier:¿Untitled?, newIdentifier: ¿test cancel?) @ W:1 18:08:05: > . . . . . SelectingNotes([¿test cancel?]) @ W:1 18:08:05: > . . . . . . ChangingSelectedNotes([¿test cancel?]) @ W:1 18:08:05: > . . . . . . DisplayingNote(¿test cancel?) @ W:1 18:08:05: > . . . . . . . ChangingDisplayedContent.note(NoteContents(¿test cancel?, 11 B, selection: TextSelection(location=0, length=11), scrolledTo: 0.0, url: file://I removed real path to file/test%20cancel.md)) @ W:1 18:08:05: 📝 Replacing note text for ¿test cancel? 18:08:05: > . . . . . . . . SelectingRangeInNote(identifier: ¿test cancel?, textSelection: TextSelection(location=0, length=11)) @ W:1 18:08:05: > . . . . . . . CompletingDisplayingNote() @ W:1 18:08:05: > . . . . . . . PushingToNavigationHistory(identifier: ¿test cancel?, workspaceContents: State.WorkspaceContents(searchResults: State.SearchResults(archiveContents: ArchiveContents([...1350 SortedArray<Note>...]), requestVersion: Req.(-12)), appendix: State.ResultAppendix(notes: [Note(fn=Filename(test cancel), "⌃(created: T(747158880.4275336), modified: T(747158883.8587186), url: file://I removed real path to file/test%20cancel.md", content="test cancel")]), editedNotes: []), search: Optional(State.PendingSearch(query: Query(""), reason: .historic, requestVersion: Req.(-11), offerSuggestion: false))) @ W:1 18:08:05: > . . . . . . . DisplayingHighlightedTerms() @ W:1 18:08:05: > . . . . . . ScrollingToHighlight() @ W:1 18:08:05: > . . . . . . . CompletingScroll() @ W:1 18:08:05: > . . . . . . ChangingOmnibarContent(omnibarContent: .select(test cancel)) @ W:1 18:08:05: > . . . . . . . CompletingChangingOmnibarContent() @ W:1 18:08:05: > . . . . . . CompletingNoteSelection() @ W:1 18:08:05: I removed real path to file/Untitled.md (596804881) changed: isFile, created, modified, renamed, inodeMetaModified, xattrsModified 18:08:05: remove(url: file://I removed real path to file/Untitled.md) 18:08:05: Swallowing expected deletion of file://I removed real path to file/Untitled.md 18:08:05: I removed real path to file/test cancel.md (596804882) changed: isFile, renamed 18:08:05: update(url: file://I removed real path to file/test%20cancel.md) 18:08:05: Swallowing duplicate insertion for ¿test cancel? 18:08:06: Text editing focus reason mouse 18:08:06: > SelectingRangeInNote(identifier: ¿test cancel?, textSelection: TextSelection(location=11, length=0)) @ W:1 18:08:07: > SelectingRangeInNote(identifier: ¿test cancel?, textSelection: TextSelection(location=5, length=6)) @ W:1 18:08:09: Forcefully ending editing, changing from focus(TheArchive.NoteTextFocus.mouse) to focus(TheArchive.NoteTextFocus.programmatic) 18:08:09: Executing plugin `de.zettelkasten.extract_note` 18:08:10: Plugin finished with error: JavaScriptError(message: "TypeError: null is not an object (evaluating \'targetFilename.trim\')", wrapped: nil) 18:08:10: > HandlingError(error: UserlandJS.JavaScriptError(message: "TypeError: null is not an object (evaluating \'targetFilename.trim\')", wrapped: nil)) Build: 249 ()Thanks for reporting this -- I changed the prompt and now it returns
nullinstead ofundefined, which goes by unchecked. Oh dear.You can fix this in the meantime with this change to the .js file:
if (targetFilename === undefined || targetFilename === null || targetFilename.trim() === "") { throw new Error("No filename provided by user"); }Author at Zettelkasten.de • https://christiantietze.de/
The fix helped.
It still shows the error dialog. But judging by stacktrace, that's ~intended processing of throwing an error:

Thank you for quick reply!
Full stacktrace:
Reported error: The operation couldn’t be completed. (UserlandJS.JavaScriptError error 1.) 19:24:40: > . . . . . . . ChangingDisplayedContent.note(NoteContents(¿0 test cancel?, 11 B, selection: TextSelection(location=0, length=11), scrolledTo: 0.0, url: file://I removed real path to file/0%20test%20cancel.md)) @ W:1 19:24:40: 📝 Replacing note text for ¿0 test cancel? 19:24:40: > . . . . . . . . SelectingRangeInNote(identifier: ¿0 test cancel?, textSelection: TextSelection(location=0, length=11)) @ W:1 19:24:40: > . . . . . . . CompletingDisplayingNote() @ W:1 19:24:40: > . . . . . . . PushingToNavigationHistory(identifier: ¿0 test cancel?, workspaceContents: State.WorkspaceContents(searchResults: State.SearchResults(archiveContents: ArchiveContents([...1350 SortedArray<Note>...]), requestVersion: Req.(-4)), appendix: State.ResultAppendix(notes: [Note(fn=Filename(0 test cancel), "⌃(created: T(747158880.4275336), modified: T(747158883.8587186), url: file://I removed real path to file/0%20test%20cancel.md", content="test cancel")]), editedNotes: []), search: Optional(State.PendingSearch(query: Query(""), reason: .historic, requestVersion: Req.(-3), offerSuggestion: false))) @ W:1 19:24:40: > . . . . . . . DisplayingHighlightedTerms() @ W:1 19:24:40: > . . . . . . ScrollingToHighlight() @ W:1 19:24:40: > . . . . . . . CompletingScroll() @ W:1 19:24:40: > . . . . . . ChangingOmnibarContent(omnibarContent: .select(0 test cancel)) @ W:1 19:24:40: > . . . . . . . CompletingChangingOmnibarContent() @ W:1 19:24:40: > . . . . . . CompletingNoteSelection() @ W:1 19:24:40: I removed real path to file/test cancel.md (596916729) changed: isFile, renamed 19:24:40: remove(url: file://I removed real path to file/test%20cancel.md) 19:24:40: Swallowing expected deletion of file://I removed real path to file/test%20cancel.md 19:24:40: I removed real path to file/0 test cancel.md (596916730) changed: isFile, renamed 19:24:40: update(url: file://I removed real path to file/0%20test%20cancel.md) 19:24:40: Swallowing duplicate insertion for ¿0 test cancel? 19:24:41: I removed real path to file/0 test cancel.md (596916775) changed: isFile, xattrsModified 19:24:41: update(url: file://I removed real path to file/0%20test%20cancel.md) 19:24:41: Swallowing duplicate insertion for ¿0 test cancel? 19:24:42: > SelectingRangeInNote(identifier: ¿0 test cancel?, textSelection: TextSelection(location=6, length=0)) @ W:1 19:24:42: Text editing focus reason mouse 19:24:42: > SelectingRangeInNote(identifier: ¿0 test cancel?, textSelection: TextSelection(location=2, length=0)) @ W:1 19:24:42: I removed real path to file/0 test cancel.md (596916832) changed: isFile, xattrsModified 19:24:42: update(url: file://I removed real path to file/0%20test%20cancel.md) 19:24:42: Swallowing duplicate insertion for ¿0 test cancel? 19:24:43: > SelectingRangeInNote(identifier: ¿0 test cancel?, textSelection: TextSelection(location=0, length=4)) @ W:1 19:24:49: > Thunk<AppState>(body: (Function)) 19:24:49: > . EnablingPlugin(pluginID: `de.zettelkasten.extract_note`) 19:24:52: Forcefully ending editing, changing from focus(TheArchive.NoteTextFocus.mouse) to focus(TheArchive.NoteTextFocus.programmatic) 19:24:52: Executing plugin `de.zettelkasten.extract_note` 19:24:53: Plugin finished with error: JavaScriptError(message: "Error: No filename provided by user", wrapped: nil) 19:24:53: > HandlingError(error: UserlandJS.JavaScriptError(message: "Error: No filename provided by user", wrapped: nil)) Build: 249 ()With the introduction of
cancel()we now have a silent way to abort executionAuthor at Zettelkasten.de • https://christiantietze.de/