I am getting the same error on a fresh-installed Moodle 3.1.3+ (Build: 20161125). It is an empty installation and I've been trying to move some courses to it from another site (the source site is Moodle 3.1.1+ Build: 20160825).
When restoring the course to the target site, I am getting:
Coding error detected, it must be fixed by a programmer: Invalid availability structure (unknown ->op)
More information about this error
Error code: codingerror
line 152 of /availability/classes/tree.php: coding_exception thrown
line 144 of /availability/classes/info.php: call to core_availability\tree->__construct()
line 114 of /availability/classes/info.php: call to core_availability\info->decode_availability()
line 318 of /availability/classes/info.php: call to core_availability\info->get_availability_tree()
line 907 of /backup/moodle2/restore_stepslib.php: call to core_availability\info->update_after_restore()
line 34 of /backup/util/plan/restore_execution_step.class.php: call to restore_update_availability->define_execution()
line 181 of /backup/util/plan/base_task.class.php: call to restore_execution_step->execute()
line 177 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
line 167 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
line 335 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
line 224 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
line 111 of /backup/restore.php: call to restore_ui->execute()
It doesn't seem to be caused by any "restrictions/availability settings unique and specific to that course", as Ken suggested, because it happens even with a course which doesn't have any restrictions.
I've done some experiments and found the same results Mateusz noticed:
If I create an empty course (with just the news forum) on the 3.1.1 site, backup this course and restore it to the 3.1.3 site, the problem does not occur.
But as soon as I edit the name and summary of the "general" section of the course, the restore process produces the "invalid availability structure" error.