Skip to content

Conversation

@remo-lab
Copy link

Description

This PR fixes a crash in the JiveXML loader caused by unguarded access to missing XML tags.

Several parsing methods in jivexml-loader.ts assume that certain XML tags are always present and directly access getElementsByTagName(...)[0].innerHTML. When a tag is missing (which happens in real JiveXML files from older versions or different experiments), this results in a runtime TypeError and 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
  • Accessing [0].innerHTML on that result throws at runtime
  • One missing optional tag causes the entire JiveXML file to fail to load
  • Users see an empty event display with no clear explanation

This pattern appears in multiple parsing functions (e.g. vertices, clusters, tracks).


What this change does

  • Adds defensive checks when reading XML tag contents
  • Treats missing tags as optional instead of fatal
  • Prevents runtime crashes due to malformed or incomplete XML
  • Allows partially valid JiveXML files to load successfully

The change is intentionally minimal and does not alter behavior when tags are present.


How to reproduce (before this fix)

  1. Load a JiveXML file containing a <RVx> collection without optional fields such as <chi2>
  2. The loader throws Cannot read properties of undefined (reading 'innerHTML')
  3. No event data is rendered

Impact

  • Improves robustness of the JiveXML loader
  • Restores compatibility with older or variant JiveXML formats
  • Prevents total failure due to a single missing field
  • Improves user experience by avoiding silent blank displays

Scope and risk

  • No API changes
  • No schema changes
  • Low risk: defensive checks only
  • Does not affect valid XML files

@remo-lab
Copy link
Author

Hi @EdwardMoyse 👋,
This addresses a crash in the JiveXML loader when optional XML tags are missing by adding simple defensive checks.

Whenever you have time, I’d appreciate a review. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant