Org-roam backlinks / org-roam-buffer-toggle issues in V2

I had no issues with backlinks in V2, but in V2 many files produce various sorts of Wrong type argument errors and fail to show backlinks.

Here an example of one such error, when trying to call org-roam-buffer-toggle:

org-roam-node-insert-section: Wrong type argument: char-or-string-p, (1 193 #("- [[https://org-roam.discourse.group/t/zero-to-emacs-and-org-roam-a-step-by-step-guide-on-windows-10/400][Zero to Emacs and Org-roam: a step-by-step guide on Windows 10 - Guides - Org-roam]]" 0 2 (line-prefix #("  " 0 2 (face org-indent)) wrap-prefix #("    " 0 2 (face org-indent) 2 4 (face org-indent)))))
Error in post-command-hook (org-roam-buffer--redisplay-h): (wrong-type-argument char-or-string-p (1 1436 ""))
Error in post-command-hook (magit-section-update-highlight): (wrong-type-argument number-or-marker-p nil)

I can’t reproduce the issue on my very vanilla Emacs 27.2.
I don’t seem to have org-roam-buffer--redisplay-h in my system; I have org-roam-buffer--redisplay instead. You might like to upgrade Org-roam to the latest and see if the problem persists?

I initially suspected that the colon “:” character was the cause; this does not seem to be the case.

If upgrading does not fix the problem, you might like to get the error stack by doing toggle-error-on-error.

updated to today’s version, tried turning off some things like org-appear in case they were interfering, but I’m still running into the same issues.

Here’s the error stack with toggle-debug-on-errorwhen I call org-roam-buffer-toggle:

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p (1 210 ""))
  org-roam-fontify-like-in-org-mode((1 210 ""))
  org-roam-node-insert-section(:source-node #s(org-roam-node :file "/home/emacsomancer/Documents/Org/org-roam/daily/2021-02-0..." :file-hash nil :file-atime (24825 42965 4814 612000) :file-mtime (24821 47505 262397 535000) :id "41b3650a-7f38-4c18-bee3-af22662d48b4" :level 0 :point 1 :todo nil :priority nil :scheduled nil :deadline nil :title "2021-02-02" :properties (("CATEGORY" . "2021-02-02") ("ID" . "41b3650a-7f38-4c18-bee3-af22662d48b4") ("BLOCKED" . "") ("FILE" . "/home/emacsomancer/Documents/Org/org-roam/daily/2021-02-0...") ("PRIORITY" . "C")) :olp nil :tags ("daily_journal") :aliases nil :refs nil) :point 210 :properties (:outline nil))
  org-roam-backlinks-section(#s(org-roam-node :file "/home/emacsomancer/Documents/Org/org-roam/20210102184440-..." :file-hash nil :file-atime (24825 42965 374809 471000) :file-mtime (24819 35310 129717 79000) :id "257a4042-830b-4397-9a7a-d245eaea3c52" :level 0 :point 1 :todo nil :priority nil :scheduled nil :deadline nil :title "Linux" :properties (("CATEGORY" . "20210102184440-linux") ("ID" . "257a4042-830b-4397-9a7a-d245eaea3c52") ("BLOCKED" . "") ("FILE" . "/home/emacsomancer/Documents/Org/org-roam/20210102184440-...") ("PRIORITY" . "C")) :olp nil :tags nil :aliases nil :refs nil))
  run-hook-with-args(org-roam-backlinks-section #s(org-roam-node :file "/home/emacsomancer/Documents/Org/org-roam/20210102184440-..." :file-hash nil :file-atime (24825 42965 374809 471000) :file-mtime (24819 35310 129717 79000) :id "257a4042-830b-4397-9a7a-d245eaea3c52" :level 0 :point 1 :todo nil :priority nil :scheduled nil :deadline nil :title "Linux" :properties (("CATEGORY" . "20210102184440-linux") ("ID" . "257a4042-830b-4397-9a7a-d245eaea3c52") ("BLOCKED" . "") ("FILE" . "/home/emacsomancer/Documents/Org/org-roam/20210102184440-...") ("PRIORITY" . "C")) :olp nil :tags nil :aliases nil :refs nil))
  org-roam-buffer-render-contents()
  org-roam-buffer-persistent-redisplay()
  org-roam-buffer-toggle()
  funcall-interactively(org-roam-buffer-toggle)
  call-interactively(org-roam-buffer-toggle nil nil)
  command-execute(org-roam-buffer-toggle)

Is it possible that the file with ID completely empty?
257a4042-830b-4397-9a7a-d245eaea3c52

the file associated with ID 257a4042-830b-4397-9a7a-d245eaea3c52 is 2021012184440-linux.org and it contains regular org-roam stuff in it (#+title etc. body text). That’s actually the file I was calling org-roam-buffer-toggle on (in other words, I was trying to get its backlinks).

or this one.

My guess is that it’s essentially a data issue in one of the files.
The stack trace seems to me that Org-roam tries to insert the backlink section for a file. For some reason, it finds an empty string as indicated here: org-roam-fontify-like-in-org-mode((1 210 “”)).

If all the backlink files look fine, I would put a debugging point in this function (and the one before, org-roam-node-insert-section) and go through edebugging sessions.

If data issue, it could point to a defect in the migration script if you used it.

edit: I don’t have the same problem. It would be very difficult for others to reproduce it. For that, you would need to identify and share the file(s) that cause the problem…

I don’t think it’s a data error. The other ID is a dailies file which is full of content. And I get this with most files, not just this one.

The org-roam-fontify-like-in-org-mode((1 210 “”)) pattern is consistent too - the second number is the “character number” of the first character in the backlink from that file to the file I started from.

Here’s the error I get from first file I mentioned (in the first post):

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p (1 193 #("- [[https://org-roam.discourse.group/t/zero-to-ema..." 0 2 (wrap-prefix #("    " 0 4 (face org-indent)) line-prefix #("  " 0 2 (face org-indent))))))
  org-roam-fontify-like-in-org-mode((1 193 #("- [[https://org-roam.discourse.group/t/zero-to-ema..." 0 2 (wrap-prefix #("    " 0 4 (face org-indent)) line-prefix #("  " 0 2 (face org-indent))))))
  org-roam-node-insert-section(:source-node #s(org-roam-node :file "/home/emacsomancer/Documents/Org/org-roam/daily/2020-12-1..." :file-hash nil :file-atime (24829 23902 394750 615000) :file-mtime (24821 47507 185731 60000) :id "f5f62cef-f183-4e28-a307-aa1ba7f78992" :level 0 :point 1 :todo nil :priority nil :scheduled nil :deadline nil :title "2020-12-18" :properties (("CATEGORY" . "2020-12-18") ("ID" . "f5f62cef-f183-4e28-a307-aa1ba7f78992") ("BLOCKED" . "") ("FILE" . "/home/emacsomancer/Documents/Org/org-roam/daily/2020-12-1...") ("PRIORITY" . "C")) :olp nil :tags ("daily_journal") :aliases nil :refs nil) :point 193 :properties (:outline nil))
  org-roam-backlinks-section(#s(org-roam-node :file "/home/emacsomancer/Documents/Org/org-roam/20201218193400-..." :file-hash nil :file-atime (24829 23895 258185 739000) :file-mtime (24819 35306 583100 326000) :id "a74d5938-5747-4e2a-871a-8d6019495617" :level 0 :point 1 :todo nil :priority nil :scheduled nil :deadline nil :title "Emacs" :properties (("CATEGORY" . "20201218193400-emacs") ("ROAM_ALIASES" . "EMACS emacs \"GNU Emacs\"") ("ID" . "a74d5938-5747-4e2a-871a-8d6019495617") ("BLOCKED" . "") ("FILE" . "/home/emacsomancer/Documents/Org/org-roam/20201218193400-...") ("PRIORITY" . "C")) :olp nil :tags nil :aliases ("EMACS" "emacs" "GNU Emacs") :refs nil))
  run-hook-with-args(org-roam-backlinks-section #s(org-roam-node :file "/home/emacsomancer/Documents/Org/org-roam/20201218193400-..." :file-hash nil :file-atime (24829 23895 258185 739000) :file-mtime (24819 35306 583100 326000) :id "a74d5938-5747-4e2a-871a-8d6019495617" :level 0 :point 1 :todo nil :priority nil :scheduled nil :deadline nil :title "Emacs" :properties (("CATEGORY" . "20201218193400-emacs") ("ROAM_ALIASES" . "EMACS emacs \"GNU Emacs\"") ("ID" . "a74d5938-5747-4e2a-871a-8d6019495617") ("BLOCKED" . "") ("FILE" . "/home/emacsomancer/Documents/Org/org-roam/20201218193400-...") ("PRIORITY" . "C")) :olp nil :tags nil :aliases ("EMACS" "emacs" "GNU Emacs") :refs nil))

Again here the (wrong-type-argument char-or-string-p (1 193 #("- ... - 193 is the character number in the file of the first character in the backlink in the file.

I’ll try debugging the functions when I have a chance, since it doesn’t look like data errors to me. (I tried deleting the .db file and forcing org-roam to rebuild it - which didn’t help either.)

Possibly the same as this GutHub issue? Jethro is making a new PR.

Edit: @emacsomancer the PR is now merged. Perhaps you can try to see if it solves your issue?

About backlinks sections and org-roam-buffer-toggle, I have got a related error in the newest commit:
Error in post-command-hook (org-roam-buffer--redisplay-h): (wrong-type-argument arrayp nil).

@eli refer to my comment earlier. I don’t have this function in my system. I believe you would need to update Org-roam first and see if the problem persists.

I have upgraded to the newest reversion: [20210726.548 ], and the functions is defined in org-roam-mode.el

Got it. Apologies; it was me who needed upgrade.

I don’t see the relation between your issue you raised in GitHub, and the one we are trying to deal with here. Yours seems to be related to the unlinked-references.

Where do you see connections?

sorry, it’s my fault

Please don’t apologise for this. It was a pure question; I don’t see anything wrong with what you have said/done here.

These issues can be related, or I might have misunderstood something. It’s good to have different eyes looking at issues from different angles.

1 Like

Reading the description, it sounds exactly like what is happening for me.

And, installing the latest from Melpa… yep, it’s fixed!

[resolved by (fix)preview: fix link preview when headline contains link by jethrokuan · Pull Request #1676 · org-roam/org-roam · GitHub ]

1 Like