extensions icon indicating copy to clipboard operation
extensions copied to clipboard

[Obsidian] Create Note closes after a failed save and accepts names that create hidden or misplaced notes

Open kirill-markin opened this issue 3 weeks ago • 0 comments

Extension

https://www.raycast.com/marcjulian/obsidian

Raycast Version

2.10.1.0

OS Version

macOS 26.6.1

Description

Create Note can look like it worked when no usable note was saved. There are two causes.

1. The form closes even when the save fails or is canceled

  • writeMarkdown (src/obsidian/internal/notes.ts:41) catches mkdirSync / writeFileSync errors, shows the "Couldn't write to file" toast and returns, but it doesn't tell the caller anything.
  • createNoteWithConfirmation (src/api/create-note.ts:58) always returns true after calling it (lines 70 and 75), so a failed write counts as saved.
  • CreateNoteForm (src/components/CreateNoteForm.tsx:29-30) calls popToRoot() and closeMainWindow() no matter what createNote returns. That includes the case where the user cancels the "Override note" dialog.
  • Result: when the write fails or the overwrite is canceled, the form closes and the typed name and content are lost. The AI tool (src/tools/createNote.ts) reports "Successfully created note" after a failed write too, because it trusts the same return value.

2. The note name is used as a filename without any checks

The final name (after the default name and templates are applied, src/api/create-note.ts:31-36) goes straight into path.join(filePath, fileName + ".md"). I ran these cases on macOS with the same fs calls and path building as the extension. The "Listed" column uses the extension's own fast-glob options (dot: false, src/api/file/file.service.ts:29):

Name entered What happens Listed by Search Note
... Writes hidden file ....md No
., .., .Task Writes hidden ..md, ...md, .Task.md No
three spaces Writes .md (a note that looks nameless) Yes
Existing/ (folder exists) Writes hidden Existing/.md No
Missing/Task (folder doesn't exist) ENOENT: only the Path folder is created, not folders from the name -
Existing/Task (folder exists) Writes Existing/Task.md. This is an undocumented second way to set the folder; the form already has a Path field Yes
../Outside Writes Outside.md one level above the target folder. From the vault root, that's outside the vault No
Task.md Writes Task.md.md Yes
253 ASCII characters ENAMETOOLONG (252 works) -

The ... case is how I ran into this: I typed ... as a title, Raycast closed the form, and the note was nowhere in Obsidian or in Search Note, because Obsidian hides files that start with a dot.

Names with ordinary punctuation work fine and should stay allowed: Task v1.2 (draft) [review], and also : (the {time} template puts 14:35:02 in names), #, ^, |, Cyrillic and emoji.

The Path field has the same traversal problem: .. segments in it can also send the note outside the vault.

Steps To Reproduce

  1. Open Create Note and select a vault.
  2. Enter ... as the name and some content, then press Create.
  3. The form closes with a "Note created" toast, but the note doesn't appear in Obsidian or in Search Note. The file on disk is <vault>/....md.

For the failed-write case:

  1. Enter Missing/Task as the name, where Missing is a folder that doesn't exist in the vault.
  2. Press Create. A "Couldn't write to file" toast appears, but the form closes and the typed content is lost.

Current Behaviour

  • The form closes and drops the user's input after a failed write or a canceled overwrite.
  • Names that are blank, start with a dot, or contain /, \ or .. create hidden files, misplaced files, files outside the vault, or confusing errors.
  • Task.md becomes Task.md.md.

Expected Behaviour

  • writeMarkdown returns whether the save succeeded, and createNote passes that on. The form closes only after a confirmed save. On a failed write or a canceled overwrite, it stays open with the input intact, and the AI tool reports the failure.
  • The final name (after defaults and templates) is checked before writing. Invalid names show an inline error on the Name field, the form stays open, and nothing is written:
    • empty or whitespace-only names
    • names starting with . (Obsidian hides them)
    • names containing / or \, with a hint to use the Path field for folders (\ is the folder separator on Windows)
  • The Path field can't point outside the vault.
  • One trailing .md in the name is dropped, so Task.md saves as Task.md.
  • Real filesystem errors such as ENAMETOOLONG keep coming from the actual write, with the form left open.

I'm preparing a PR with this fix and tests.

kirill-markin avatar Nov 06 '26 08:11 kirill-markin