From d98bec53665f4530fc959f55037d2e8d8b1345d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20R=C3=ADos?= Date: Sun, 10 Nov 2024 06:17:31 +0100 Subject: [PATCH] fix: skip malformed `sboms` (#2461) --- .../oso_dagster/dlt_sources/github_repos/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/warehouse/oso_dagster/dlt_sources/github_repos/__init__.py b/warehouse/oso_dagster/dlt_sources/github_repos/__init__.py index 524078a30..300c405fc 100644 --- a/warehouse/oso_dagster/dlt_sources/github_repos/__init__.py +++ b/warehouse/oso_dagster/dlt_sources/github_repos/__init__.py @@ -11,7 +11,7 @@ import dlt from oso_dagster.factories.dlt import pydantic_to_dlt_nullable_columns import polars as pl -from pydantic import BaseModel +from pydantic import BaseModel, ValidationError from githubkit import GitHub from githubkit.exception import RequestFailed from githubkit.versions.latest.models import ( @@ -324,6 +324,16 @@ def get_sbom_for_repo( else: logger.warning("Error getting SBOM: %s", exception) return [] + except ValidationError as exception: + validation_errors = [ + f"{error['loc'][0]}: {error['msg']}" for error in exception.errors() + ] + logger.warning( + "Skipping %s, SBOM is malformed: %s", + f"{owner}/{name}", + ", ".join(validation_errors), + ) + return [] @staticmethod def get_github_client(config: GithubClientConfig) -> GitHub: