obsidian-linter: Bug: Malformed Table Hangs Linter

Describe the Bug

Malformed tables (e.g. incorrect header syntax) cause linter to hang indefinitely.

How to Reproduce

Lint the attached example markdown file which contains a malformed table: “Malformed Table Hangs Linter.md”

Please make sure to include logs and the rule(s) that cause the issue if applicable. You can include logs by going to the debug tab of the Linter and setting the log level to debug. Then enable the capturing of logs and either lint on save or lint the current file. Then go back to the debug tab and you can grab Linter logs from the last run. > Logs are not produced so unable to provide them.

If you are not sure which rule(s) may cause the issue, please attach the data.json file located at <vault>/.obsidian/plugins/obsidian-linter/ or copy the config from the debug tab.

data.json attached. I am unclear which rule causes the issue.

Expected Behavior

Linting is not expected to transform malformed tables, so it should just ignore them in that case.

Screenshots

NA

Device

  • Desktop
  • Mobile

Additional Context

This bug makes it very difficult to bulk lint large folders since only one malformed table causes linter to hang and very difficult to find the troublesome file.

data.json.zip Malformed Table Hangs Linter.md

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19

Most upvoted comments

I believe that this is fixed now on master and will go out in the next release. Please let us know if this is not true on master or in the next release.

Also, the Linter does not try to fix the table. Trying to determine if a table is present in the file is what is causing the issue in this case.

@pjkaufman Thanks for the quick reply and confirmation on the issue.

For clarity, I don’t expect linter to fix the table issues. I appreciate that fixing them is a nightmare (I think I have aged 10 years writing regexes to fix them). However, some possible ways to reduce the impact of this issue would be:

  1. Ignore whatever it is that is causing linter to hang, or if you know the malformed syntax that is causing the issue, I could possible write a regex to fix at least fix that.
  2. Offer some way of identifying the troublesome markdown file that is causing the hang (so that I could manually fix the table). I could not see any way of doing this with Chome Dev Tools.

I tried looking for a way to kill the regex processing if it took more than a minute or 2 to run and then log the error, but it seems that is not really feasible. I am not sure what is causing the regex to hang exactly and there is no good way of doing that from what I can tell. Since I have little experience diagnosing problems with regex except via trial and error, I am not sure I can do much on that front. I may have to shift to another package and see if it alleviates this issue without creating another performance issue.

@grantx2016 , what you are requesting here is a lot harder said than done. Parsing tables is already super difficult in markdown and creates problems. If I were to force the use of a specific markdown table format, then the performance could be greatly improved, but as of right now, I have been unable to find a good way to parse tables.

I have used a markdown parser, but long files caused issues https://github.com/platers/obsidian-linter/issues/458 and now it seems that the regex that is more performant, but may not be as accurate is also having performant is also having issues. I am not sure I can fix this as it stands, but I do appreciate the notice about the issue.