[SilverStripe 3.1] "[object Object]" is not valid JSON error on LeftAndMain.js

Silverstripe Version: 3.1.9


I’m trying to ressurect an old Silverstripe site that’s been out of maintenance for years. I have it running in Docker using the brettt89/silverstripe-web:5.6-apache image.

It’s all working, except when I log into the CMS Admin I get endless messages in the browser console. I’m not doing anything, I just login into the CMS and see these console messages:

VM1458:1 Uncaught SyntaxError: "[object Object]" is not valid JSON
    at JSON.parse (<anonymous>)
    at LeftAndMain.js?m=1444622234:42:17
    at dispatch (jquery.js?m=1444622229:3332:9)
    at eventHandle (jquery.js?m=1444622229:2941:28)

The error is happening at this JSON.Parse statement:

	$.entwine('ss', function($) {
		 * Handle messages sent via nested iframes
		 * Messages should be raised via postMessage with an object with the 'type' parameter given.
		 * An optional 'target' and 'data' parameter can also be specified. If no target is specified
		 * events will be sent to the window instead.
		 * type should be one of:
		 *  - 'event' - Will trigger the given event (specified by 'event') on the target
		 *  - 'callback' - Will call the given method (specified by 'callback') on the target
		$(window).on("message", function(e) {
			var target,
				event = e.originalEvent,
				data = JSON.parse(event.data);

Any hints as to what the problem is and how to fix would be appreciated. Doing a full upgrade to the latest SilverStripe is not on the cards with my client at the moment.