Studio's having trouble saving your work

Hello,

it is happening to some users that saving work in the studio fails, with the following error: “Studio’s having trouble saving your work. This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.”

In my case, it does not happen in Firefox but it does happen in Brave. Digging into the developer tools I have found that the error is due to the POST request to save the changes returning a Forbidden 403 error of the form “CSRF verification failed. Request aborted.” (note that the same request returns a 200 status code in Firefox so everything works correctly).

The CMS logs for the failing request (in Brave) are as follows:

tutor_local-cms-1  | 2023-01-31 06:57:06,612 INFO 26 [tracking] [user 6] [ip 194.230.158.119] logger.py:41 - {"name": "/settings/details/course-v1:EPFL+VA_PGU+2022", "context": {"user_id": 6, "path": "/settings/details/course-v1:EPFL+VA_PGU+2022", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "martibosch", "session": "2010d6eeb1ba3002e67ba310314d7eaf", "ip": "194.230.158.119", "agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36", "host": "studio.courses.africancitieslab.org", "referer": "https://studio.courses.africancitieslab.org/settings/details/course-v1:EPFL+VA_PGU+2022", "accept_language": "en-US,en;q=0.5", "event": "{\"GET\": {}, \"POST\": {}}", "time": "2023-01-31T06:57:06.611879+00:00", "event_type": "/settings/details/course-v1:EPFL+VA_PGU+2022", "event_source": "server", "page": null}
tutor_local-cms-1  | 2023-01-31 06:57:06,632 WARNING 26 [django.security.csrf] [user 6] [ip 194.230.158.119] log.py:224 - Forbidden (CSRF token missing or incorrect.): /settings/details/course-v1:EPFL+VA_PGU+2022
tutor_local-cms-1  | [uwsgi-http key: studio.courses.africancitieslab.org client_addr: 172.18.0.3 client_port: 45234] hr_instance_read(): Connection reset by peer [plugins/http/http.c line 647]
tutor_local-cms-1  | [pid: 26|app: 0|req: 313/3229] 172.18.0.3 () {60 vars in 3858 bytes} [Tue Jan 31 06:57:06 2023] POST /settings/details/course-v1:EPFL+VA_PGU+2022 => generated 1019 bytes in 49 msecs (HTTP/1.1 403) 7 headers in 379 bytes (1 switches on core 0)

whereas the logs for a successful request (in Firefox) are:

tutor_local-cms-1  | 2023-01-31 07:04:37,791 INFO 7 [tracking] [user 6] [ip 194.230.158.119] logger.py:41 - {"name": "/settings/details/course-v1:EPFL+VA_PGU+2022", "context": {"user_id": 6, "path": "/settings/details/course-v1:EPFL+VA_PGU+2022", "course_id": "", "org_id": "", "enterprise_uuid": ""}, "username": "martibosch", "session": "def6beb60d6f5969296176e4dea92346", "ip": "194.230.158.119", "agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/109.0", "host": "studio.courses.africancitieslab.org", "referer": "https://studio.courses.africancitieslab.org/settings/details/course-v1:EPFL+VA_PGU+2022", "accept_language": "en-US,en;q=0.5", "event": "{\"GET\": {}, \"POST\": {}}", "time": "2023-01-31T07:04:37.791147+00:00", "event_type": "/settings/details/course-v1:EPFL+VA_PGU+2022", "event_source": "server", "page": null}
tutor_local-cms-1  | 2023-01-31 07:04:37,807 INFO 7 [openedx.core.djangoapps.cors_csrf.helpers] [user 6] [ip 194.230.158.119] helpers.py:64 - Origin 'https://studio.courses.africancitieslab.org' was not in `CORS_ORIGIN_WHITELIST`; full referer was 'https://studio.courses.africancitieslab.org/settings/details/course-v1:EPFL+VA_PGU+2022' and requested host was 'studio.courses.africancitieslab.org'; CORS_ORIGIN_ALLOW_ALL=False
tutor_local-cms-1  | 2023-01-31 07:04:38,750 INFO 7 [openedx.core.djangoapps.content.course_overviews.models] [user 6] [ip 194.230.158.119] models.py:290 - Attempting to load CourseOverview for course course-v1:EPFL+VA_PGU+2022 from modulestore.
tutor_local-cms-1  | 2023-01-31 07:04:38,754 INFO 7 [openedx.core.djangoapps.content.course_overviews.models] [user 6] [ip 194.230.158.119] models.py:190 - Updating course overview for course-v1:EPFL+VA_PGU+2022.
tutor_local-cms-1  | 2023-01-31 07:04:38,815 INFO 7 [openedx.core.djangoapps.course_date_signals.handlers] [user 6] [ip 194.230.158.119] handlers.py:125 - Extracting course dates for course-v1:EPFL+VA_PGU+2022
tutor_local-cms-1  | 2023-01-31 07:04:38,829 INFO 7 [edx_when.api] [user 6] [ip 194.230.158.119] api.py:94 - Setting date for BlockUsageLocator(CourseLocator('EPFL', 'VA_PGU', '2022', None, None), 'course', 'course'), start, datetime.datetime(2023, 1, 1, 0, 0, tzinfo=<bson.tz_util.FixedOffset object at 0x7faa81c3d1c0>)
tutor_local-cms-1  | 2023-01-31 07:04:38,834 INFO 7 [edx_when.api] [user 6] [ip 194.230.158.119] api.py:94 - Setting date for BlockUsageLocator(CourseLocator('EPFL', 'VA_PGU', '2022', None, None), 'course', 'course'), end, datetime.datetime(2050, 1, 1, 0, 0, tzinfo=<bson.tz_util.FixedOffset object at 0x7faa81c3d1c0>)
tutor_local-cms-1  | 2023-01-31 07:04:38,866 INFO 7 [celery_utils.logged_task] [user 6] [ip 194.230.158.119] logged_task.py:25 - Task lms.djangoapps.discussion.tasks.update_discussions_map[6c10c8db-feba-46b7-ae83-fb25db832898] submitted with arguments [{'course_id': 'course-v1:EPFL+VA_PGU+2022'}], None
tutor_local-cms-1  | 2023-01-31 07:04:38,867 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function listen_for_course_publish at 0x7faaad221940> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,867 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function export_course_metadata at 0x7faaad22f820> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,867 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function _listen_for_course_publish at 0x7faaac755430> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,868 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function _listen_for_course_publish at 0x7faaac755700> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,868 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function update_block_structure_on_course_publish at 0x7faaac760a60> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,868 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function _listen_for_course_publish at 0x7faaac76c940> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,868 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function extract_dates at 0x7faaac615040> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,869 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function trigger_update_xblocks_cache_task at 0x7faaac57f430> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,869 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function update_course_apps at 0x7faaac58a040> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | 2023-01-31 07:04:38,869 INFO 7 [xmodule.modulestore.django] [user 6] [ip 194.230.158.119] django.py:212 - Sent course_published signal to <function update_discussions_on_course_publish at 0x7faaac58a790> with kwargs {'course_key': CourseLocator('EPFL', 'VA_PGU', '2022', None, None)}. Response was: None
tutor_local-cms-1  | [pid: 7|app: 0|req: 311/3270] 172.18.0.3 () {60 vars in 2667 bytes} [Tue Jan 31 07:04:37 2023] POST /settings/details/course-v1:EPFL+VA_PGU+2022 => generated 9096 bytes in 1117 msecs (HTTP/1.1 200) 8 headers in 547 bytes (1 switches on core 0)

I have found a related post from 2019 that points to an issue with celery and rabbitmq (which in tutor would be redis I suppose), but it does not seem to be the same.

Any ideas on how to fix this?
Thank you. Best,
Martí