Fixes attachment handling in client side aasx handling#1118
Fixes attachment handling in client side aasx handling#1118aaronzi merged 5 commits intoeclipse-basyx:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves client-side AASX import/packaging behavior by making supplementary file resolution more robust, fixing attachment upload path generation for SubmodelElementList children (indexed paths), and refining thumbnail handling so internal thumbnail endpoints aren’t mistakenly treated as external.
Changes:
- Enhance supplementary part selection by considering decoded + sanitized filename candidates.
- Fix attachment upload
idShortPathconstruction to include bracket indexes forSubmodelElementListitems (e.g.,Markings[0]). - Update thumbnail fetching logic to respect
defaultThumbnail.isExternalwhile still guarding against truly external URLs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| aas-web-ui/src/composables/AAS/AASXPackaging.ts | Adjusts external-thumbnail detection so repository-internal thumbnail endpoints aren’t skipped. |
| aas-web-ui/src/composables/AAS/AASXImport.ts | Improves supplementary-file matching and fixes attachment upload path traversal to include list indices. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR improves client-side AASX attachment import/export by normalizing package paths, centralizing filename/path-segment sanitization, and fixing attachment upload path construction for SubmodelElementList indices (addressing the missing [0] issue from #1117). It also refactors key helpers to be exported for direct unit testing and updates/expands the test suite accordingly.
Changes:
- Introduces a shared
safeSegment()sanitization helper and refactors AASX import/packaging to use it. - Enhances supplementary-part selection logic (candidate generation + ambiguity handling) and fixes attachment upload traversal to include list indices.
- Adds focused unit tests for
StringUtils,AASXImport, andAASXPackaginghelpers; removes older regression tests now covered elsewhere.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| aas-web-ui/src/utils/StringUtils.ts | Adds reusable safeSegment() helper for sanitizing file/path segments. |
| aas-web-ui/src/composables/AAS/AASXImport.ts | Exports path helpers; improves supplementary-part matching; fixes attachment traversal to include list indices. |
| aas-web-ui/src/composables/AAS/AASXPackaging.ts | Uses shared sanitization; exports resolveAttachmentFilename; refines external thumbnail handling. |
| aas-web-ui/tests/utils/StringUtils.test.ts | Adds unit tests for safeSegment(). |
| aas-web-ui/tests/composables/AAS/AASXImport.test.ts | Adds unit tests for new/now-exported AASX import helpers. |
| aas-web-ui/tests/composables/AAS/AASXPackaging.test.ts | Adds unit tests for packaging helpers (fetch path + filename resolution). |
| aas-web-ui/tests/composables/AAS/AASXPathHandling.test.ts | Removes redundant regression tests superseded by the new focused tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Related Issue
Closes #1117
This pull request improves the handling and matching of attachment file paths and names in AASX import/export logic, with a focus on robust filename sanitization and path normalization. It introduces a reusable string sanitization utility, refactors related code to use this utility, and adds comprehensive unit tests for these helpers. Additionally, ambiguity in filename-only matching is now handled explicitly to prevent incorrect file associations.
Attachment path and filename sanitization:
Introduced a new
safeSegmentutility inStringUtils.tsfor sanitizing strings to be safe for path/file segments, and refactored both import and export logic to use this shared function instead of duplicating the sanitization code. (aas-web-ui/src/utils/StringUtils.ts,aas-web-ui/src/composables/AAS/AASXImport.ts,aas-web-ui/src/composables/AAS/AASXPackaging.ts) [1] [2] [3] [4]Enhanced the logic in
pickSupplementaryPartto match attachments using sanitized, decoded, and original filenames, and to avoid ambiguous filename-only matches by returningnullif multiple candidates are found. (aas-web-ui/src/composables/AAS/AASXImport.ts)Path normalization and candidate generation:
normalizePackagePath,packagePathCandidates, andpickSupplementaryPartpublic exports for better testability and modularity. (aas-web-ui/src/composables/AAS/AASXImport.ts) [1] [2] [3]Attachment filename and path resolution:
resolveAttachmentFilenameto be a public export, ensuring that file naming during packaging uses the new sanitization logic and falls back to safe defaults. (aas-web-ui/src/composables/AAS/AASXPackaging.ts)Submodel element path handling:
collectAttachmentUploadsto accurately handle array indices in submodel element lists and propagate parent type information, ensuring correct path construction for attachments. (aas-web-ui/src/composables/AAS/AASXImport.ts) [1] [2]Testing improvements:
AASXImport,AASXPackaging, andStringUtils, and removed redundant regression tests now covered by these targeted tests. (aas-web-ui/tests/composables/AAS/AASXImport.test.ts,aas-web-ui/tests/composables/AAS/AASXPackaging.test.ts,aas-web-ui/tests/utils/StringUtils.test.ts,aas-web-ui/tests/composables/AAS/AASXPathHandling.test.ts) [1] [2] [3] [4] [5]These changes collectively make attachment handling more robust, maintainable, and easier to test.