[hub] getBuildType: ensure id exists in buildinfo dict

if there is no id, call `get_build` to fetch the build data (n-v-r inside will be used or the data is invalid)

fixes: #3091
This commit is contained in:
Yuming Zhu 2021-10-21 16:43:55 +08:00 committed by Yu Ming Zhu
parent 1eaeb45e94
commit d367420c75

View file

@ -4261,7 +4261,7 @@ def get_build(buildInfo, strict=False):
"""Return information about a build.
buildInfo may be either a int ID, a string NVR, or a map containing
'name', 'version' and 'release.
'name', 'version' and 'release'.
A map will be returned containing the following keys*:
id: build ID
@ -4708,7 +4708,7 @@ def get_build_type(buildInfo, strict=False):
Returns a dictionary whose keys are type names and whose values are
the type info corresponding to that type
"""
if not isinstance(buildInfo, dict) or 'extra' not in buildInfo:
if not isinstance(buildInfo, dict) or 'extra' not in buildInfo or 'id' not in buildInfo:
binfo = get_build(buildInfo, strict=strict)
if not binfo:
return None