From 5d9b522e902b502b0d221e82b8fa5e8999b110e5 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 7 Mar 2019 14:40:16 -0500 Subject: [PATCH] Fix an NPE on the repository API endpoint Not all tags will have legacy images anymore --- endpoints/api/repository_models_pre_oci.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/endpoints/api/repository_models_pre_oci.py b/endpoints/api/repository_models_pre_oci.py index 690a66fc0..f59f3f63b 100644 --- a/endpoints/api/repository_models_pre_oci.py +++ b/endpoints/api/repository_models_pre_oci.py @@ -159,12 +159,15 @@ class PreOCIModel(RepositoryDataInterface): tags = None repo_ref = RepositoryReference.for_repo_obj(repo) if include_tags: - tags, _ = registry_model.list_repository_tag_history(repo_ref, page=1, size=max_tags, active_tags_only=True) + tags, _ = registry_model.list_repository_tag_history(repo_ref, page=1, size=max_tags, + active_tags_only=True) tags = [ - Tag(tag.name, tag.legacy_image.docker_image_id, tag.legacy_image.aggregate_size, - tag.lifetime_start_ts, - tag.manifest_digest, - tag.lifetime_end_ts) for tag in tags + Tag(tag.name, + tag.legacy_image.docker_image_id if tag.legacy_image_if_present else None, + tag.legacy_image.aggregate_size if tag.legacy_image_if_present else None, + tag.lifetime_start_ts, + tag.manifest_digest, + tag.lifetime_end_ts) for tag in tags ] start_date = datetime.now() - timedelta(days=MAX_DAYS_IN_3_MONTHS)