Skip to content

Handle roleless SBOL2 components during import - #462

Open
simplyshree wants to merge 1 commit into
SynBioDex:finalfrom
simplyshree:handle-roleless-sbol2-import
Open

Handle roleless SBOL2 components during import#462
simplyshree wants to merge 1 commit into
SynBioDex:finalfrom
simplyshree:handle-roleless-sbol2-import

Conversation

@simplyshree

@simplyshree simplyshree commented Jul 30, 2026

Copy link
Copy Markdown

Summary

Fixes an SBOL2 import failure path where SBOLCanvas assumes every ComponentDefinition has at least one role.

Root Cause

SBOLToMx.java checked for circular-backbone components by calling:

cd.getRoles().iterator().next()

Valid SBOL2 ComponentDefinition objects may legally have an empty role set. When a roleless component is imported, such as a generic GenBank misc_feature annotation, this can throw NoSuchElementException and cause Canvas import to fail.

Convert.java then hid unchecked exceptions without messages behind the generic response Export failed, making the real import failure difficult to diagnose.

Changes

  • Replaced the first-role lookup with a safe membership check using cd.getRoles().contains(...).
  • Added a small errorMessage(Throwable e) helper so conversion failures include the exception class, even when the exception message is null.

Impact

This makes SBOL2 import robust for standards-valid roleless components and also correctly detects circular-backbone roles when a component has multiple roles and the circular role is not first.

Validation

  • git diff --check passed.
  • Backend Maven tests Passed (Tests run: 67)

Notes

SeqTrainer has a workaround that assigns generic Sequence Ontology role SO:0000110 (sequence_feature) to source features without a narrower mapping, but Canvas should still handle roleless valid SBOL2 components safely.

@cjmyers
cjmyers requested a review from travisformayor July 31, 2026 16:50
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