From 980ca03685e674ef6cda7b5383aede84dff44560 Mon Sep 17 00:00:00 2001 From: Luke Yang Date: Wed, 11 Oct 2023 13:39:28 -0400 Subject: [PATCH] tools/osbuild-mpp: Fix empty ostree commit object in deploy stage This adds an early return to the `_process_ostree_commits` function to prevent an empty ostree commit object from being created in the deploy stage which causes violations to the deploy stage input schema. --- tools/osbuild-mpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/osbuild-mpp b/tools/osbuild-mpp index 1333c017..5ed866d7 100755 --- a/tools/osbuild-mpp +++ b/tools/osbuild-mpp @@ -1622,6 +1622,17 @@ class ManifestFileV2(ManifestFile): return inputs = element_enter(stage, "inputs", {}) + + # The ostree.deploy stage accepts both containers or + # ostree commits as input. If this is an ostree.deploy + # stage and there are no commits in the inputs then let's + # return early. This prevents an empty "commits" object + # from being created when a container image is used as + # an input to ostree.deploy and not an ostree commit. + if stage.get("type", "") == "org.osbuild.ostree.deploy": + if "commits" not in inputs: + return + inputs_commits = element_enter(inputs, "commits", {}) if inputs_commits.get("type", "") != "org.osbuild.ostree":