Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: When opening command palette: Command failed to execute: obsidian-linter:lint-all-files-in-folder #1182

Open
2 of 3 tasks
chrisgrieser opened this issue Oct 3, 2024 · 9 comments
Labels
bug Something isn't working obsidian Obsidian specific syntax issue or feature

Comments

@chrisgrieser
Copy link
Contributor

  • I have verified that I am on the latest version of the Linter

Describe the Bug

An error occurs when opening the command palette for the first time after opening the vault. As far as I can tell, other than the error msg, there is nothing happening – but I do hope that the linter does not try to run commands simply when I open the command palette?

How to Reproduce

Steps to reproduce the behavior:

  1. Open vault
  2. Open Command palette
  3. The error appears in the console:
Command failed to execute:  obsidian-linter:lint-all-files-in-folder
app.js:1 TypeError: Cannot read properties of null (reading 'parent')
    at Object.editorCheckCallback (plugin:obsidian-linter:307:3438)
    at e.mobileOnly.Il.isMobile.e.checkCallback (app.js:1:2068235)
    at app.js:1:2068860
    at Array.filter (<anonymous>)
    at e.listCommands (app.js:1:2068798)
    at e.getCommands (app.js:1:2660005)
    at t.getItems (app.js:1:2661047)
    at t.getSuggestions (app.js:1:1709952)
    at t.updateSuggestions (app.js:1:1709135)
    at t.onOpen (app.js:1:1708977)

Expected Behavior

No error happening.

Device

  • Desktop
  • Mobile

Additional Context

I am on Obsidian 1.7.3 (Insider release)

@chrisgrieser chrisgrieser added the bug Something isn't working label Oct 3, 2024
@pjkaufman
Copy link
Collaborator

Hey @chrisgrieser , are you using the latest BRAT release? I updated the minimum node version to 18, but recently saw that maybe some versions of Obsidian still expect 16.x.

@pjkaufman
Copy link
Collaborator

If it is having issues, I can see about fixing that, but the Linter is not running commands onload.

@pjkaufman
Copy link
Collaborator

I just double checked some code. I probably need to not assume that the editor callback will be called for a file object. I need to check if that exists and if it does not return false.

The error seems to be happening on the validation check that tries to check if a command should show in the editor.

@chrisgrieser
Copy link
Contributor Author

Hey @chrisgrieser , are you using the latest BRAT release?

Nope, I am on the latest regular release of the linter

@pjkaufman
Copy link
Collaborator

pjkaufman commented Oct 3, 2024

Gotcha. So that rules out the node change. I am pretty sure it is the check on this line that needs extra guards:

return !ctx.file.parent.isRoot();

Is the file you are looking at a custom view or is there no file open? Those are my two best guesses as to what would cause this unless it is a new bug where the ctx is not getting file info populated.

Edit: I cannot really look into this myself when it comes to reproducing the error until tomorrow.

@chrisgrieser
Copy link
Contributor Author

it's a regular file.

Also, I double-checked, and it appears that the error only occurs after a vault reload (by running the command Reload app without saving), not on regular vault startup.

@pjkaufman
Copy link
Collaborator

Interesting. I will have to double check that then. Thanks for the reproduction information!

@pjkaufman pjkaufman added the obsidian Obsidian specific syntax issue or feature label Oct 3, 2024
@pjkaufman
Copy link
Collaborator

I am not able to reproduce this issue, but I will add some logic to be more defensive when checking that logic to avoid an error.

@pjkaufman
Copy link
Collaborator

Here is a potential fix for this issue, but it does include the BRAT/beta features:
main.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working obsidian Obsidian specific syntax issue or feature
Projects
None yet
Development

No branches or pull requests

2 participants