Skip to content

set-default didn't check for wrong input, causing silent errors #78

@Foxtr0t1337

Description

@Foxtr0t1337

Describe the bug
MacOS
obsidian-cli set-default accepts path (even though README.md says no)
Now in obsidian:// vault param will be illegal, and everything would break silently if no x-callback-url is provided (Obsidian.app may complain "Vault not found.")

To Reproduce
Steps to reproduce the behaviour:

>obsidian-cli set-default "/var/workspace/obsidian" 
Default vault set to:  /var/workspace/obsidian
Default vault path set to:  /private/var/workspace/obsidian
>obsidian-cli create "New note" 

It didn't work here. Cli no output. But app complained about "Vault not found."

>obsidian-cli --version
obsidian-cli version v0.2.3

And if there are multiple vaults with the same name, can't distinguish based on vault name.
I think in the src "default vault path" is ignored for obsidian://?
So it's undefined behavior? (some tests show Obsidian.app just defaults to the first with the exact name?)

Expected behaviour
1.Detecting it was path and get the name properly.
2.Using vault ID instead of vault Name for obsidian://

Proposed solution
According to Obsidian URI:

obsidian://open?vault=my%20vault
Didn't specify which my vault if there are more than one with the same name.
The document didn't define the behavior?

obsidian://open?vault=ef6ca3e3b524d22f
Specified unique ID, should resolve the issue.

obsidian://open?path=%2Fhome%2Fuser%2Fmy%20vault%2Fpath%2Fto%2Fmy%20note
Auto find proper vault, but I think ID would be better.

In pkg/obsidian/vault.go instead of Name, use Id.
For Path(), we can directly use indexing to find it.
For Name, it would be the directory name?
For obsidian://, we can use Id directly.
For --vault or set-default, we can accept path, name, and id. Find the id if path/name. Warn & read back path if name collided?
But I don't know what is SetDefaultName() for, so I don't know if this modification would break anything.

I haven't been using Obsidian for too long, so there might be inaccuracies, sorry for that.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions