It was a bug in the QPY serialization. qiskit 1.4.1 and qiskit 2.0.0 have fixes for it.
qiskit 1.4.1
qiskit 2.0.0