Skip to content

Commit b9a84b5

Browse files
committed
fix: prevent error if version not set
Signed-off-by: Paul Horton <[email protected]>
1 parent a1bbf00 commit b9a84b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

cyclonedx/output/json.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def _recurse_specialise_component(self, bom_json: Dict[Any, Any], base_key: str
151151
if not self.component_supports_author() and 'author' in bom_json[base_key][i].keys():
152152
del bom_json[base_key][i]['author']
153153

154-
if self.component_version_optional() and bom_json[base_key][i].get('version', '') == "":
154+
if self.component_version_optional() and 'version' in bom_json[base_key][i] \
155+
and bom_json[base_key][i].get('version', '') == "":
155156
del bom_json[base_key][i]['version']
156157

157158
if not self.component_supports_pedigree() and 'pedigree' in bom_json[base_key][i].keys():

0 commit comments

Comments
 (0)