In my opinion the function: (org-heading-components) shall not error, no matter if it is called outside of the heading, it could still return nil values if it is outside of the header.
Debugger entered--Lisp error: (wrong-type-argument stringp nil) looking-at(nil) org-heading-components() eval((org-heading-components) nil) elisp--eval-last-sexp(nil) eval-last-sexp(nil) funcall-interactively(eval-last-sexp nil) call-interactively(eval-last-sexp nil nil) command-execute(eval-last-sexp) Emacs : GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.6, Xaw3d scroll bars) of 2022-12-16 Package: Org mode version 9.4.3 (9.4.3-elpa @ /home/data1/protected/.emacs.d/elpa/org-20201216/) -- Jean Take action in Free Software Foundation campaigns: https://www.fsf.org/campaigns In support of Richard M. Stallman https://stallmansupport.org/