How can I fix AJAX error when trying to attached a media entity to a node?

I’m using Drupal 8.7.2 and have added a media reference field to my article node bundle.

When I try to select a media item to attach I just get an AJAX error as show in the image. There is nothing showing in watchdog and as far as I can tell the site is working fine besides this issue.

Can anyone tell me how to debug/fix this issue?

The AJAX error message appears to be a rendered page from the site.

enter image description here