Skip to content

Commit 39496f5

Browse files
committed
imgtestlib: handle missing sources key in tests
Prevent a KeyError crash when accessing org.osbuild.curl for missing sources.
1 parent 29dd241 commit 39496f5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/scripts/imgtestlib/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,11 @@ def can_boot_test(manifest_fname, manifest_data, image_type, arch, distro, bluep
428428
"FATAL: FIPS integrity test failed")
429429
return False
430430
# Note that this needs adjustment when we switch to librepo
431-
urls = [src["url"] for src in manifest_data["sources"]["org.osbuild.curl"]["items"].values()]
431+
curl_items = manifest_data.get("sources", {}).get("org.osbuild.curl", {}).get("items", {})
432+
if not curl_items:
433+
print(f" not bootable: no org.osbuild.curl source in manifest {manifest_fname} ({arch} {image_type})")
434+
return False
435+
urls = [src["url"] for src in curl_items.values()]
432436
if not any("ssh-server" in url for url in urls):
433437
# This can happen e.g. when an image is build with the "minimal: true" customization.
434438
# We could use guestfs to inject keys, see PR#1995

0 commit comments

Comments
 (0)