Repository navigation
Handle roleless SBOL2 components during import - #462
Conversation
|
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? |
There was a problem hiding this comment.
🟢 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
SBOLToMxby checking role membership withcontains(...)instead of reading the “first role”. - Improve servlet error responses in
Convertby 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.
|
@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
left a comment
There was a problem hiding this comment.
Approve. Looks like a good fix on a crash condition, and good to see a unit test added for it as well.
Summary
Fixes an SBOL2 import failure path where SBOLCanvas assumes every
ComponentDefinitionhas at least one role.Root Cause
SBOLToMx.javachecked for circular-backbone components by calling:Valid SBOL2
ComponentDefinitionobjects may legally have an empty role set. When a roleless component is imported, such as a generic GenBankmisc_featureannotation, this can throwNoSuchElementExceptionand cause Canvas import to fail.Convert.javathen hid unchecked exceptions without messages behind the generic responseExport failed, making the real import failure difficult to diagnose.Changes
cd.getRoles().contains(...).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 --checkpassed.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.