-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: video page api error #34883
fix: video page api error #34883
Conversation
if current_course: | ||
values['course_video_image_url'] = current_course[0][course_id] | ||
else: | ||
values['course_video_image_url'] = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
values['course_video_image_url'] = '' | |
values['course_video_image_url'] = None |
@@ -690,7 +690,10 @@ def _get_values(video, course): | |||
for attr in attrs: | |||
if attr == 'courses': | |||
current_course = [c for c in video['courses'] if course_id in c] | |||
(__, values['course_video_image_url']), = list(current_course[0].items()) | |||
if current_course: | |||
values['course_video_image_url'] = current_course[0][course_id] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you don't keep the original code and just wrap it in a the if/else that you creates here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed better in terms of clarity. I believe using list() and items() iterates twice as well which is worse for performance but that's not a big deal here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. I am still slightly confused why you are indexing the dict with the course_id. Is that how you get the image url? If you could add a comment in to code to clarify this it would help me understand more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the video
looked like this from working it out backwards. And current_course
is only populated with entries if course_id in c
.
video = {
'courses': [
{
'course_id_123': 'img.url',
...
},
],
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the example! It definitely clears up my confusion
1cc23d4
to
046c3cb
Compare
046c3cb
to
74079ea
Compare
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
Description
When there is corruption in course video data, we can run into the following error:
This causes the api to not return course video data even if one url is missing (and subsequently causes the course video page to not load at all).
This PR ensures that the IndexError is not triggered so the api call can at least return as much information as it can.
Supporting information
https://2u-internal.atlassian.net/browse/TNL-11628
Testing instructions
Test on stage by accessing https://course-authoring.stage.edx.org/course/course-v1:edx+gc_6+2024_T1/videos/.
It should not show an error.