Skip to content

fix(externalIds): handle package-url stored as JSON array string#1617

Open
bibhuti230185 wants to merge 3 commits intoeclipse-sw360:mainfrom
siemens:fix/package-url-external-key
Open

fix(externalIds): handle package-url stored as JSON array string#1617
bibhuti230185 wants to merge 3 commits intoeclipse-sw360:mainfrom
siemens:fix/package-url-external-key

Conversation

@bibhuti230185
Copy link
Copy Markdown
Contributor

Summary

Old SW360 backend stored multiple package-url values as a single JSON array string (e.g., ["pkg:maven/...", "pkg:npm/..."]). The new UI could not properly display, edit, or save these entries.

Problem

  • Display showed the raw JSON array string instead of individual URLs
  • Edit mode showed a single row with the entire array as the value
  • Adding a new package-url would overwrite all existing values (Map.set behavior)

Solution

Modified 3 files to handle the JSON array format:

File Change
src/utils/common.utils.ts convertObjectToMap() now expands package-url JSON arrays into multiple entries when reading
src/components/sw360/AddKeyValue/AddKeyValue.tsx Added convertListToMap() that merges multiple package-url entries back into JSON array when saving
src/components/ExternalIds/ExternalIds.tsx Added expandExternalIds() to display each package URL on its own line

Testing

  • Created test component with package-url: ["pkg:maven/org.apache.commons/[email protected]","pkg:npm/@angular/[email protected]"]
  • Verified display shows 2 separate entries
  • Verified edit mode shows 2 editable rows
  • Verified saving preserves JSON array format for backend compatibility
Screenshot 2026-04-10 180602 Screenshot 2026-04-10 180707

Edge Cases Handled

  • Empty JSON array [] - no entries created
  • Invalid JSON - falls back to displaying as-is
  • Leading whitespace - handled with trimStart()
  • Empty values on save - skipped

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.

2 participants