Is this only happening when the course is one with a single activity format? I can't replicate this in such a course as it works as expected for me, but I wonder if this is issue related to this Tracker
MDL-73532 which added the secondary navigation to single activity courses in 4.0.
The error message above shows that this error is happening when trying to load the secondary menu in a single activity course. I wonder if this can happen for users not enrolled or who don't have role assignments in the course or some other specific condition.
Anyone familiar with the details of this process want to chime in?