TypeError: Cannot create property 'stack' on string 'Forbidden'

TypeError: Cannot create property 'stack' on string 'Forbidden'

by U Zarni Moe Myint -
Number of replies: 9

Dear All,

I am newbie  in Moodle, I have a issue "TypeError: Cannot create property 'stack' on string 'Forbidden' in Dashboard page.

May I know the solutions for this error. Please see the attachment for error screen short.


Thanks, Please help

Attachment error.png
Average of ratings: -
In reply to U Zarni Moe Myint

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by S P -

Dashboard-Admin login getting this erroram getting a similar issue like this

In reply to S P

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by Santiago Sandoval -

I have the same error. how do you fixit?

Thanks

Kind Regards

In reply to U Zarni Moe Myint

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by Santiago Sandoval -
I have the same error. how do you fixit?

Thanks

Kind Regards
In reply to U Zarni Moe Myint

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by Mahmut TEKER -
Has anyone found solution to this error?
In reply to U Zarni Moe Myint

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by Artur Welp -
This happened on the installation a give suport to.
Also, if i tried to access the user profile as other user, the browser show a 500 error and the whole request died.

I think it happen because I made a batch update on the user profiles, configuring the imagealt column on the user table.

So, i fixed the user profile with this SQL:
UPDATE mdl_user set imagealt = '' WHERE username = 'admin';

In reply to U Zarni Moe Myint

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by Artur Welp -
I posted a possible reason for the problem... But, I found that other things can cause this problem as well.

Last year, we migrated the moodle version and one course format was removed, and we created a script to manage the configurations for all this courses with no format. 
For what I debuged, this error may happen when the course overview try to render a course with some miss configuration. The course would also return a 500 code on rendering.

I pinned down the course that would give a 500 result and rebuild the cache for the format with this snippet on a php sandbox:

define('CLI_SCRIPT', true)
require_once('config.php');
rebuild_course_cache(11111);
course_get_format(11111)->update_course_format_options(array());
The course format was topics. This is important, you might mess the config with this script!
This worked for the students enrolled on this course...
But there is still teachers with this problem that I could not find the reason for. So I will keep diggin and posting updates on this thread.
Average of ratings: Useful (1)
In reply to Artur Welp

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by Mustafa Hajjar -
Was a solution ever found for this issue? we are experiencing this after the upgrade as well on one of our plugins. The error is not on dev or staging environments!

Thanks,
Mustafa
In reply to Mustafa Hajjar

Re: TypeError: Cannot create property 'stack' on string 'Forbidden'

by Artur Welp -
Not yet.

This error is like to catch smoke with the hands.

This happens in two instances today.

  • One when a specific course is related to a user;
  • In the other, when a message is sent with a special character like a emoji.

In the first instance, the error ocorr when the course summary try to load this course. Also, if the user profile page is loaded, a 500 error is thrown. I didn't dig much further, but in the profile page I could track to this files:
user/profile.php:198
╚> lib/outputrenderers.php:1298
For some reason, this error did not happens on the development machine, wich the database is loaded, but not the moodledata. So I unenroled the user from the course and noted to fix this on the version 4 of Moodle. Now the user is happy.

The second case I did not dig anything.