Skip to content

Commit 6f7e09a

Browse files
authored
Merge pull request #194 from CycloneDX/fix/json-output-version-optional-bug-193
fix: `version` being optional in JSON output can raise error
2 parents 87c490e + b9a84b5 commit 6f7e09a

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]['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)