This mwe:
\DocumentMetadata{testphase=new-or-1}
\documentclass{book}
\usepackage{hyperref}
\usepackage[ocgcolorlinks]{ocgx2}
\begin{document}
\tableofcontents
\chapter{first chapter}
\end{document}
produces, in the console, the following error:
(./ocgx2.toc
! Undefined control sequence.
\pdf_object_new:nn ...\__pdf_backend_object_new:n
{#1}
l.1 ...\numberline {1}first chapter}{3}{chapter.1}
%
The error occurs only with the ocgcolorlinks
option.
Finally, all my documents with this 'configuration' (i.e. the simultaneous presence of the testphase=new-or-1
key, the ocgcolorlinks
option and the \tableofcontents
command) always compiled correctly.