Fix JiveXML loader crash when optional XML tags are missing #780
+36
−71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a crash in the JiveXML loader caused by unguarded access to missing XML tags.
Several parsing methods in
jivexml-loader.tsassume that certain XML tags are always present and directly accessgetElementsByTagName(...)[0].innerHTML. When a tag is missing (which happens in real JiveXML files from older versions or different experiments), this results in a runtimeTypeErrorand prevents the entire event from loading.Instead of failing hard on a single missing field, the parser should degrade gracefully and continue loading available data.
What was happening
getElementsByTagName()returns an empty collection when a tag is missing[0].innerHTMLon that result throws at runtimeThis pattern appears in multiple parsing functions (e.g. vertices, clusters, tracks).
What this change does
The change is intentionally minimal and does not alter behavior when tags are present.
How to reproduce (before this fix)
<RVx>collection without optional fields such as<chi2>Cannot read properties of undefined (reading 'innerHTML')Impact
Scope and risk