From 61b8bd4d7abc997743988dcf444b2ed67f2d1a5b Mon Sep 17 00:00:00 2001 From: Gregory Martin Date: Wed, 31 Jan 2018 16:58:51 -0500 Subject: [PATCH] Update video record handling defensiveness --- cms/djangoapps/contentstore/views/videos.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/views/videos.py b/cms/djangoapps/contentstore/views/videos.py index 315522e0c4..c36e95acde 100644 --- a/cms/djangoapps/contentstore/views/videos.py +++ b/cms/djangoapps/contentstore/views/videos.py @@ -6,6 +6,7 @@ import json import logging from contextlib import closing from datetime import datetime, timedelta +from pytz import UTC from uuid import uuid4 import rfc6266 @@ -505,7 +506,11 @@ def convert_video_status(video): * `YouTube Duplicate` if status is `invalid_token` * user-friendly video status """ - now = datetime.now(video['created'].tzinfo) + try: + # Protect against legacy incomplete edx-val edx_video_id records. + now = datetime.now(video['created'].tzinfo) + except AttributeError: + now = datetime.now().replace(tzinfo=UTC) if video['status'] == 'upload' and (now - video['created']) > timedelta(hours=MAX_UPLOAD_HOURS): new_status = 'upload_failed' status = StatusDisplayStrings.get(new_status)