coddingtonbear / obsidian-local-rest-api

Unlock your automation needs by interacting with your notes in Obsidian over a secure REST API.
MIT License
607 stars 56 forks source link

[Bug] Server hang after requesting folder for file-related `/vault/{filename}` endpoints #23

Closed kaiiiz closed 2 years ago

kaiiiz commented 2 years ago

Consider the following folder structure:

.
├── a
│   └── a.md
└── b

Request /vault/{filename} related endpoints with filename = a (a is a folder, not a valid file).

What I get from the server response: It's completely hung.

image

Similar results can get from GET, PUT, POST, DELETE endpoints.

What I expected to get from the server response:

It should return some errors instead of hanging (maybe 405 Bad Request?)

OS: MacOS Monterey 12.2.1 (M1) Obsidian version: 0.14.6 Obsidian local rest API version: 1.3.5

kaiiiz commented 2 years ago

I notice a related issue, for the PUT /vault/{filename} endpoint, if the specified folder in the path doesn't exist, the server will hang forever. (e.g. filename = c/d.md and folder c doesn't exist)

image

What I expected to get from the server response:

It should return 405 Bad Request or create the nested folder structure before creating the new file (maybe an optional parameter for this functionality?).

coddingtonbear commented 2 years ago

I notice a related issue, for the PUT /vault/{filename} endpoint, if the specified folder in the path doesn't exist, the server will hang forever. (e.g. filename = c/d.md and folder c doesn't exist)

image

What I expected to get from the server response:

It should return 405 Bad Request or create the nested folder structure before creating the new file (maybe an optional parameter for this functionality?).

For this issue -^ I've created #24.

coddingtonbear commented 2 years ago

Thanks for another very thorough bug report; I've fixed this in c9bc41e.