From 82b5bf6c8f2bbc9f20b6f665c7b20f21a50421ad Mon Sep 17 00:00:00 2001 From: Jesper Hodge Date: Thu, 9 Jan 2025 17:00:12 -0500 Subject: [PATCH] fix: broken links not showing up --- .../contentstore/core/course_optimizer_provider.py | 5 ++++- cms/djangoapps/contentstore/tasks.py | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cms/djangoapps/contentstore/core/course_optimizer_provider.py b/cms/djangoapps/contentstore/core/course_optimizer_provider.py index 9a6ecfdaebeb..b4121642a96d 100644 --- a/cms/djangoapps/contentstore/core/course_optimizer_provider.py +++ b/cms/djangoapps/contentstore/core/course_optimizer_provider.py @@ -55,7 +55,10 @@ def generate_broken_links_descriptor(json_content, request_user): for item in json_content: block_id, link, *rest = item - is_locked_flag = bool(rest[0]) + if rest: + is_locked_flag = bool(rest[0]) + else: + is_locked_flag = False usage_key = usage_key_with_run(block_id) block = get_xblock(usage_key, request_user) diff --git a/cms/djangoapps/contentstore/tasks.py b/cms/djangoapps/contentstore/tasks.py index 451bc9221ea0..b047f3618b68 100644 --- a/cms/djangoapps/contentstore/tasks.py +++ b/cms/djangoapps/contentstore/tasks.py @@ -1214,12 +1214,13 @@ def retry_validation(url_list, course_key, retry_count=3): for i in range(0, retry_count): if retry_list: LOGGER.debug(f'[Link Check] retry attempt #{i+1}') - validated_url_list = asyncio.run(validate_urls_access_in_batches(retry_list, course_key, batch_size=100)) + validated_url_list = asyncio.run( + validate_urls_access_in_batches(retry_list, course_key, batch_size=100) + ) filetered_url_list, retry_list = filter_by_status(validated_url_list) results.extend(filetered_url_list) - - if retry_list: - LOGGER.debug(f'[Link Check] {len(retry_list)} requests failed due to connection error') + + results.extend(retry_list) return results @@ -1237,7 +1238,7 @@ def filter_by_status(results): filtered_results = [] retry_list = [] for result in results: - if result['status'] == None: + if result['status'] is None: retry_list.append([result['block_id'], result['url']]) elif result['status'] == 200: continue