Skip to content

Handle roleless SBOL2 components during import - #462

Merged
cjmyers merged 3 commits into
SynBioDex:finalfrom
simplyshree:handle-roleless-sbol2-import
Sep 10, 2026
Merged

cjmyers merged 3 commits into
SynBioDex:finalfrom
simplyshree:handle-roleless-sbol2-import

Conversation

@simplyshree

@simplyshree simplyshree commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

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
@simplyshree

simplyshree commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor Author

The Azure Static Web Apps check appears to be failing because the repository deployment secret is unavailable in this PR context. if we could either configure the repository token or temporarily set SKIP_DEPLOY_ON_MISSING_SECRETS: true, so the build can complete while deployment is skipped?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The production changes address the import crash path safely and add targeted tests, with only minor non-blocking test maintainability feedback.

Pull request overview

This PR hardens SBOL2 import in the backend by removing an unsafe assumption that every ComponentDefinition has at least one role, and improves conversion error reporting so role-related failures are diagnosable instead of surfacing as a generic “Export failed”.

Changes:

  • Fix circular-backbone detection in SBOLToMx by checking role membership with contains(...) instead of reading the “first role”.
  • Improve servlet error responses in Convert by including the exception type when the exception message is null.
  • Add a regression test covering roleless components and multi-role circular-backbone detection.
File summaries
File Description
SBOLCanvasBackend/src/test/java/org/sbolcanvas/utils/SBOLToMxRoleHandlingTest.java Adds regression coverage for roleless component import and circular-backbone detection with multiple roles.
SBOLCanvasBackend/src/main/java/org/sbolcanvas/utils/SBOLToMx.java Avoids NoSuchElementException by replacing iterator().next() with a safe role membership check.
SBOLCanvasBackend/src/main/java/org/sbolcanvas/servlets/Convert.java Ensures conversion failures include exception class info when messages are missing.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cjmyers

cjmyers commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@travisformayor Please let me us know if you approve this PR

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@travisformayor travisformayor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. Looks like a good fix on a crash condition, and good to see a unit test added for it as well.

@cjmyers
cjmyers merged commit 55e2b2f into SynBioDex:final Sep 10, 2026
4 of 5 checks passed
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.

4 participants