From 673ea0dfcad97e268da2be958dc42dc1cdcd6001 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 19 Jan 2021 15:54:21 +0000 Subject: [PATCH] formats/v1: properly format failed results When the build fails, not all pipelines might have been built and those pipelines will be missing from the results. Currently the code assumes that all pipelines will have a result and this will crash when trying to find an id for an pipeline that did not get built. --- osbuild/formats/v1.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/osbuild/formats/v1.py b/osbuild/formats/v1.py index 2413a5e0..e30e9f5a 100644 --- a/osbuild/formats/v1.py +++ b/osbuild/formats/v1.py @@ -110,8 +110,14 @@ def output(manifest: Manifest, res: Dict) -> Dict: """Convert a result into the v1 format""" def result_for_pipeline(pipeline): - current = res[pipeline.id] - retval = {"success": current["success"]} + # The pipeline might not have been built one of its + # dependencies, i.e. its build pipeline, failed to + # build. We thus need to be tolerant of a missing + # result but still need to to recurse + current = res.get(pipeline.id, {}) + retval = { + "success": current.get("success", False) + } if pipeline.build: build = manifest[pipeline.build] retval["build"] = result_for_pipeline(build)