fix(fossid-webapp): Return empty PURL when artifact name is empty#11537
fix(fossid-webapp): Return empty PURL when artifact name is empty#11537nnobelis wants to merge 1 commit intooss-review-toolkit:mainfrom
Conversation
e44b210 to
8f3820a
Compare
| .withVersion(snippet.version) | ||
| .build() | ||
| .canonicalize() | ||
| val snippetPurl = snippet.purl |
There was a problem hiding this comment.
Writing:
when {
snippet.purl != null -> snippet.purl
Does not work because it returns String? (Kotlin cannot make a smart cast to String maybe ?)
There was a problem hiding this comment.
Weird that smart-cast does not work in this case. Then I'd prefer
snippet.purl != null -> checkNotNull(snippet.purl)
Is this really a fixup for that commit? Because this change is specific to FossID. @maennchen, should you commit 334810d maybe have been Pub-specific as well? In what context exactly did you come across the issue? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11537 +/- ##
=========================================
Coverage 57.97% 57.97%
Complexity 1730 1730
=========================================
Files 349 349
Lines 12993 12993
Branches 1263 1263
=========================================
Hits 7533 7533
Misses 4995 4995
Partials 465 465
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
It's a fixup for c14f781 maybe? |
|
@nnobelis f1eadd8 would make more sense. @sschuberth The commit 334810d was specifically targeting a failing test in the Pub Plugin. The fix here makes sense. It was already wrong before f1eadd8 since it would've created an invalid purl without a name. It would probably be good to add a test for this specific behavior. |
The packageurl-jvm library throws MalformedPackageURLException when the name component is empty. This can happen for snippets with empty artifact names. Return an empty string early when the name is blank. This is a fixup for f1eadd8. Signed-off-by: Nicolas Nobelis <nicolas.nobelis@bosch.com>
8f3820a to
5b1ebe1
Compare
@maennchen, so my point is, instead of ort/model/src/main/kotlin/utils/PurlExtensions.kt Lines 93 to 95 in 4af9208 should we rather change something in the Pub analyzer so that such invalid PURLs are not being created in the first place? |
|
@sschuberth I'm not a 100% sure anymore from the top of my head. But I think |
See #11538. |
| mappedSnippets shouldHaveSize 1 | ||
| mappedSnippets.first().apply { |
There was a problem hiding this comment.
This can be combined as mappedSnippets.shouldBeSingleton {.
The packageurl-jvm library throws MalformedPackageURLException when the name component is empty. This can happen for snippets with empty artifact names.
Return an empty string early when the name is blank.
This is a fixup for f1eadd8.