Bibtex-valid-entry: Wrong type argument: stringp, nil

When I try to get items from doi-add-bibtex-entry and isbn-to-bibtex it gives the following error:


bibtex-valid-entry: Wrong type argument: stringp, nil

How do I troubleshoot this? I’m using Doom Emacs and my config.org has the following:

* Org-Bibtex
#+begin_src emacs-lisp
(use-package! org-roam-bibtex
  :after org-roam
  :config
  (require 'org-ref)) ; optional: if Org Ref is not loaded anywhere else, load it here
(setq reftex-default-bibliography '("~/Dropbox/org/Zettelkasten/library.bib"))

    (setq org-ref-bibliography-notes "~/Droppbox/org/Zettelkasten/ref_notes.org"
          org-ref-default-bibliography '("~/Dropbox/org/Zettelkasten/library.bib")
          org-ref-pdf-directory "~/pdf/")

    (setq bibtex-completion-bibliography "~/Dropbox/org/Zettelkasten/library.bib"
          bibtex-completion-library-path "~/Dropbox/org/Zettelkasten/pdf"
          bibtex-completion-notes-path "~/Dropbox/org/Zettelkasten/notes")

    ; Optional. Open pdf in external viewer.
    (setq bibtex-completion-pdf-open-function
          (lambda (fpath)
            (start-process "open" "*open*" "open" fpath)))
#+end_src

Actually the config above is working from DOI numbers. But just not ISBN. But I get a strange error:

bibtex-format-entry: Mandatory field ‘journaltitle’ is missing

This is the messages buffer from testing. The bibtex-valid-entry: wrong type argument: stringgp, nil is from the ISBN. The rest is a sample DOI number.


bibtex-valid-entry: Wrong type argument: stringp, nil
Contacting host: doi.org:443
(:given MADELINE :family CARR :sequence first :affiliation [(:name Senior Lecturer in International Politics and the Cyber Dimension at Aberystwyth University.)])
Title of the work
Journal "International Affairs" not found in org-ref-bibtex-journal-abbreviations.
bibtex-format-entry: Mandatory field ‘journaltitle’ is missing
Buffer library.bib is modified; kill anyway? (y or n) n
user-error: Aborted
Wrote /home/pharper/Dropbox/org/Zettelkasten/library.bib
"Dropbox/org/Zettelkasten/library.bib" 47L, 1549C written

Figured out how to use M-x toggle-debug-on error. But I still don’t understand the output.

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  looking-at(nil)
  bibtex-valid-entry(t)
  bibtex-end-of-entry()
  bibtex-narrow-to-entry()
  oricb-remove-enclosing-brackets()
  #f(compiled-function (x) #<bytecode 0x1e09cd1e0addb>)(oricb-remove-enclosing-brackets)
  mapc(#f(compiled-function (x) #<bytecode 0x1e09cd1e0addb>) (oricb-remove-enclosing-brackets oricb-clean-author-field oricb-remove-period oricb-kill-fields oricb-replace-field-names))
  org-ref-isbn-clean-bibtex-entry()
  isbn-to-bibtex("0143126563" "~/Dropbox/org/Zettelkasten/references/library.bib")
  funcall-interactively(isbn-to-bibtex "0143126563" "~/Dropbox/org/Zettelkasten/references/library.bib")
  call-interactively(isbn-to-bibtex record nil)
  command-execute(isbn-to-bibtex record)
  counsel-M-x-action("isbn-to-bibtex")
  ivy-call()
  #f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a string, normally ending in a colon and a space.\n`ivy-count-format' is prepended to PROMPT during completion.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table, supplied for `minibuffer-completion-table'.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for compatibility with `completing-read'.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected.\n\nIf INITIAL-INPUT is non-nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nPRESELECT, when non-nil, determines which one of the candidates\nmatching INITIAL-INPUT to select initially.  An integer stands\nfor the position of the desired candidate in the collection,\ncounting from zero.  Otherwise, use the first occurrence of\nPRESELECT in the collection.  Comparison is first done with\n`equal'.  If that fails, and when applicable, match PRESELECT as\na regular expression.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the candidate list is re-displayed.\n\nWhen SORT is non-nil, `ivy-sort-functions-alist' determines how\nto sort candidates before displaying them.\n\nACTION is a function to call after selecting a candidate.\nIt takes one argument, the selected candidate. If COLLECTION is\nan alist, the argument is a cons cell, otherwise it's a string.\n\nMULTI-ACTION, when non-nil, is called instead of ACTION when\nthere are marked candidates. It takes the list of candidates as\nits only argument. When it's nil, ACTION is called on each marked\ncandidate.\n\nUNWIND is a function of no arguments to call before exiting.\n\nRE-BUILDER is a function transforming input text into a regex\npattern.\n\nMATCHER is a function which can override how candidates are\nfiltered based on user input.  It takes a regex pattern and a\nlist of candidates, and returns the list of matching candidates.\n\nDYNAMIC-COLLECTION is a boolean specifying whether the list of\ncandidates is updated after each input by calling COLLECTION.\n\nEXTRA-PROPS is a plist that can be used to store\ncollection-specific session-specific data.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode -0x157575453c0f41bc>)("M-x " ("toggle-debug-on-error" "org-ref-debug" "doi-add-bibtex-entry" "isbn-to-bibtex" "vterm" "cd" "elfeed" "doi-utils-google-scholar" "elfeed-update" "5x5" "amx" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "orc" "orn" "oro" "orp" "oru" "pdb" "pwd" "rsh" "sdb" "wos" "xdb" "=rss" "calc" "diff" "dirs" "emms" "ffap" "gnus" "grep" "help" "ielm" "info" "life" "mail" "mpuz" "mu4e" "orcb" ...) :predicate counsel--M-x-externs-predicate :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  apply(#f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a string, normally ending in a colon and a space.\n`ivy-count-format' is prepended to PROMPT during completion.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table, supplied for `minibuffer-completion-table'.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for compatibility with `completing-read'.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected.\n\nIf INITIAL-INPUT is non-nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nPRESELECT, when non-nil, determines which one of the candidates\nmatching INITIAL-INPUT to select initially.  An integer stands\nfor the position of the desired candidate in the collection,\ncounting from zero.  Otherwise, use the first occurrence of\nPRESELECT in the collection.  Comparison is first done with\n`equal'.  If that fails, and when applicable, match PRESELECT as\na regular expression.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the candidate list is re-displayed.\n\nWhen SORT is non-nil, `ivy-sort-functions-alist' determines how\nto sort candidates before displaying them.\n\nACTION is a function to call after selecting a candidate.\nIt takes one argument, the selected candidate. If COLLECTION is\nan alist, the argument is a cons cell, otherwise it's a string.\n\nMULTI-ACTION, when non-nil, is called instead of ACTION when\nthere are marked candidates. It takes the list of candidates as\nits only argument. When it's nil, ACTION is called on each marked\ncandidate.\n\nUNWIND is a function of no arguments to call before exiting.\n\nRE-BUILDER is a function transforming input text into a regex\npattern.\n\nMATCHER is a function which can override how candidates are\nfiltered based on user input.  It takes a regex pattern and a\nlist of candidates, and returns the list of matching candidates.\n\nDYNAMIC-COLLECTION is a boolean specifying whether the list of\ncandidates is updated after each input by calling COLLECTION.\n\nEXTRA-PROPS is a plist that can be used to store\ncollection-specific session-specific data.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode -0x157575453c0f41bc>) ("M-x " ("toggle-debug-on-error" "org-ref-debug" "doi-add-bibtex-entry" "isbn-to-bibtex" "vterm" "cd" "elfeed" "doi-utils-google-scholar" "elfeed-update" "5x5" "amx" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "orc" "orn" "oro" "orp" "oru" "pdb" "pwd" "rsh" "sdb" "wos" "xdb" "=rss" "calc" "diff" "dirs" "emms" "ffap" "gnus" "grep" "help" "ielm" "info" "life" "mail" "mpuz" "mu4e" "orcb" ...) :predicate counsel--M-x-externs-predicate :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x))
  ivy-posframe--read(#f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a string, normally ending in a colon and a space.\n`ivy-count-format' is prepended to PROMPT during completion.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table, supplied for `minibuffer-completion-table'.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for compatibility with `completing-read'.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected.\n\nIf INITIAL-INPUT is non-nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nPRESELECT, when non-nil, determines which one of the candidates\nmatching INITIAL-INPUT to select initially.  An integer stands\nfor the position of the desired candidate in the collection,\ncounting from zero.  Otherwise, use the first occurrence of\nPRESELECT in the collection.  Comparison is first done with\n`equal'.  If that fails, and when applicable, match PRESELECT as\na regular expression.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the candidate list is re-displayed.\n\nWhen SORT is non-nil, `ivy-sort-functions-alist' determines how\nto sort candidates before displaying them.\n\nACTION is a function to call after selecting a candidate.\nIt takes one argument, the selected candidate. If COLLECTION is\nan alist, the argument is a cons cell, otherwise it's a string.\n\nMULTI-ACTION, when non-nil, is called instead of ACTION when\nthere are marked candidates. It takes the list of candidates as\nits only argument. When it's nil, ACTION is called on each marked\ncandidate.\n\nUNWIND is a function of no arguments to call before exiting.\n\nRE-BUILDER is a function transforming input text into a regex\npattern.\n\nMATCHER is a function which can override how candidates are\nfiltered based on user input.  It takes a regex pattern and a\nlist of candidates, and returns the list of matching candidates.\n\nDYNAMIC-COLLECTION is a boolean specifying whether the list of\ncandidates is updated after each input by calling COLLECTION.\n\nEXTRA-PROPS is a plist that can be used to store\ncollection-specific session-specific data.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode -0x157575453c0f41bc>) "M-x " ("toggle-debug-on-error" "org-ref-debug" "doi-add-bibtex-entry" "isbn-to-bibtex" "vterm" "cd" "elfeed" "doi-utils-google-scholar" "elfeed-update" "5x5" "amx" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "orc" "orn" "oro" "orp" "oru" "pdb" "pwd" "rsh" "sdb" "wos" "xdb" "=rss" "calc" "diff" "dirs" "emms" "ffap" "gnus" "grep" "help" "ielm" "info" "life" "mail" "mpuz" "mu4e" "orcb" ...) :predicate counsel--M-x-externs-predicate :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  apply(ivy-posframe--read #f(compiled-function (arg1 arg2 &rest rest) "Read a string in the minibuffer, with completion.\n\nPROMPT is a string, normally ending in a colon and a space.\n`ivy-count-format' is prepended to PROMPT during completion.\n\nCOLLECTION is either a list of strings, a function, an alist, or\na hash table, supplied for `minibuffer-completion-table'.\n\nPREDICATE is applied to filter out the COLLECTION immediately.\nThis argument is for compatibility with `completing-read'.\n\nWhen REQUIRE-MATCH is non-nil, only members of COLLECTION can be\nselected.\n\nIf INITIAL-INPUT is non-nil, then insert that input in the\nminibuffer initially.\n\nHISTORY is a name of a variable to hold the completion session\nhistory.\n\nKEYMAP is composed with `ivy-minibuffer-map'.\n\nPRESELECT, when non-nil, determines which one of the candidates\nmatching INITIAL-INPUT to select initially.  An integer stands\nfor the position of the desired candidate in the collection,\ncounting from zero.  Otherwise, use the first occurrence of\nPRESELECT in the collection.  Comparison is first done with\n`equal'.  If that fails, and when applicable, match PRESELECT as\na regular expression.\n\nDEF is for compatibility with `completing-read'.\n\nUPDATE-FN is called each time the candidate list is re-displayed.\n\nWhen SORT is non-nil, `ivy-sort-functions-alist' determines how\nto sort candidates before displaying them.\n\nACTION is a function to call after selecting a candidate.\nIt takes one argument, the selected candidate. If COLLECTION is\nan alist, the argument is a cons cell, otherwise it's a string.\n\nMULTI-ACTION, when non-nil, is called instead of ACTION when\nthere are marked candidates. It takes the list of candidates as\nits only argument. When it's nil, ACTION is called on each marked\ncandidate.\n\nUNWIND is a function of no arguments to call before exiting.\n\nRE-BUILDER is a function transforming input text into a regex\npattern.\n\nMATCHER is a function which can override how candidates are\nfiltered based on user input.  It takes a regex pattern and a\nlist of candidates, and returns the list of matching candidates.\n\nDYNAMIC-COLLECTION is a boolean specifying whether the list of\ncandidates is updated after each input by calling COLLECTION.\n\nEXTRA-PROPS is a plist that can be used to store\ncollection-specific session-specific data.\n\nCALLER is a symbol to uniquely identify the caller to `ivy-read'.\nIt is used, along with COLLECTION, to determine which\ncustomizations apply to the current completion session." #<bytecode -0x157575453c0f41bc>) ("M-x " ("toggle-debug-on-error" "org-ref-debug" "doi-add-bibtex-entry" "isbn-to-bibtex" "vterm" "cd" "elfeed" "doi-utils-google-scholar" "elfeed-update" "5x5" "amx" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "orc" "orn" "oro" "orp" "oru" "pdb" "pwd" "rsh" "sdb" "wos" "xdb" "=rss" "calc" "diff" "dirs" "emms" "ffap" "gnus" "grep" "help" "ielm" "info" "life" "mail" "mpuz" "mu4e" "orcb" ...) :predicate counsel--M-x-externs-predicate :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x))
  ivy-read("M-x " ("toggle-debug-on-error" "org-ref-debug" "doi-add-bibtex-entry" "isbn-to-bibtex" "vterm" "cd" "elfeed" "doi-utils-google-scholar" "elfeed-update" "5x5" "amx" "arp" "dbx" "dig" "erc" "ert" "eww" "ftp" "gdb" "irc" "jdb" "man" "mpc" "orc" "orn" "oro" "orp" "oru" "pdb" "pwd" "rsh" "sdb" "wos" "xdb" "=rss" "calc" "diff" "dirs" "emms" "ffap" "gnus" "grep" "help" "ielm" "info" "life" "mail" "mpuz" "mu4e" "orcb" ...) :predicate counsel--M-x-externs-predicate :require-match t :history counsel-M-x-history :action counsel-M-x-action :keymap (keymap (67108908 . counsel--info-lookup-symbol) (67108910 . counsel-find-symbol)) :initial-input nil :caller counsel-M-x)
  counsel-M-x()
  funcall-interactively(counsel-M-x)
  call-interactively(counsel-M-x nil nil)
  command-execute(counsel-M-x)

First of all, Org-roam-bibtex and Org-bibtex (and Org-ref and Helm-bibtex and etc.) are different, independent packages. Org-roam-bibtex does not provide doi-add-bibtex-entry, this function is provided by doi-utils, which comes together with Org-ref. So the error you get is irrelevant to your Org-roam-bibtex config…

That said, the error you get signals that the BibTeX entry that doi-add-bibtex-entry fetches from the Internet is missing the mandatory field journaltitle. Now this field is only mandatory in the biblatex dialect of BibTeX. I bet you have bibtex-dialect, a variable of the built-in bibtex.el library, set to biblatex, while the entries fetched from DOI come in the standard BibTeX dialect, which uses the journal field and not the journaltitle field.

Unfortunately, without patching doi-utils you don’t have many options: either switch to the BibTeX dialect or refrain from using this library.