From 99837dfaf7a21927a8e1cf1f544fdcbb9bb69bf3 Mon Sep 17 00:00:00 2001 From: brianjbuck-wgu Date: Thu, 5 Mar 2026 14:26:17 -0700 Subject: [PATCH] fix: log warning when INSTRUCTOR_MICROFRONTEND_URL is unset (#38000) --- .../instructor/tests/test_api_v2.py | 19 +++++++++++++++++++ .../instructor/views/serializers_v2.py | 8 ++++++++ lms/envs/devstack.py | 1 + 3 files changed, 28 insertions(+) diff --git a/lms/djangoapps/instructor/tests/test_api_v2.py b/lms/djangoapps/instructor/tests/test_api_v2.py index 79e55dfdc6..61797e1e93 100644 --- a/lms/djangoapps/instructor/tests/test_api_v2.py +++ b/lms/djangoapps/instructor/tests/test_api_v2.py @@ -494,6 +494,25 @@ class CourseMetadataViewTest(SharedModuleStoreTestCase): self.assertIn('course_errors', response.data) self.assertIsInstance(response.data['course_errors'], list) + @patch('lms.djangoapps.instructor.views.serializers_v2.settings.INSTRUCTOR_MICROFRONTEND_URL', None) + def test_tabs_log_warning_when_mfe_url_not_set(self): + """ + Test that a warning is logged when INSTRUCTOR_MICROFRONTEND_URL is not set. + """ + with self.assertLogs('lms.djangoapps.instructor.views.serializers_v2', level='WARNING') as cm: + tabs = self._get_tabs_from_response(self.staff) + + self.assertTrue( + any('INSTRUCTOR_MICROFRONTEND_URL is not set' in msg for msg in cm.output) + ) + # Tab URLs should use empty string as base, not "None" + for tab in tabs: + self.assertFalse(tab['url'].startswith('None'), f"Tab URL should not start with 'None': {tab['url']}") + self.assertTrue( + tab['url'].startswith('/instructor/'), + f"Tab URL should start with '/instructor/': {tab['url']}" + ) + def test_pacing_self_for_self_paced_course(self): """ Test that pacing is 'self' for self-paced courses. diff --git a/lms/djangoapps/instructor/views/serializers_v2.py b/lms/djangoapps/instructor/views/serializers_v2.py index 6251dc5c50..04c97450b2 100644 --- a/lms/djangoapps/instructor/views/serializers_v2.py +++ b/lms/djangoapps/instructor/views/serializers_v2.py @@ -5,6 +5,8 @@ These serializers handle data validation and business logic for instructor dashb Following REST best practices, serializers encapsulate most of the data processing logic. """ +import logging + from django.conf import settings from django.utils.html import escape from django.utils.translation import gettext as _ @@ -33,6 +35,8 @@ from xmodule.modulestore.django import modulestore from .tools import get_student_from_identifier, parse_datetime, DashboardError +log = logging.getLogger(__name__) + class CourseInformationSerializerV2(serializers.Serializer): """ @@ -79,6 +83,10 @@ class CourseInformationSerializerV2(serializers.Serializer): course_key = course.id mfe_base_url = settings.INSTRUCTOR_MICROFRONTEND_URL + if not mfe_base_url: + log.warning('INSTRUCTOR_MICROFRONTEND_URL is not set.') + mfe_base_url = '' + access = { 'admin': request.user.is_staff, 'instructor': bool(has_access(request.user, 'instructor', course)), diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index dd7097df71..cca704e065 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -398,6 +398,7 @@ COMMUNICATIONS_MICROFRONTEND_URL = 'http://localhost:1984' AUTHN_MICROFRONTEND_URL = 'http://localhost:1999' AUTHN_MICROFRONTEND_DOMAIN = 'localhost:1999' EXAMS_DASHBOARD_MICROFRONTEND_URL = 'http://localhost:2020' +INSTRUCTOR_MICROFRONTEND_URL = 'http://localhost:2003' CATALOG_MICROFRONTEND_URL = 'http://localhost:1998/catalog' ################### FRONTEND APPLICATION DISCUSSIONS ###################