Skip to content

Commit 19c4658

Browse files
authored
fix: null pointer exception error fields [IDE-1581] (#745)
* fix: use correct error fields in tree node text methods Fix NullPointerException issues in getNewIacTreeNodeText and getNewOssTreeNodeText: - In getNewIacTreeNodeText: use currentIacError instead of currentSnykCodeError when currentIacError is not null - In getNewOssTreeNodeText: use currentOssError instead of currentSnykCodeError when realError is true Both methods were accessing the wrong error field, which could be null and cause NullPointerExceptions. * fix: improve error handling consistency in tree node text - Fixed OSS to check errors before scanning status (matching IAC and Code Security) - Fixed IAC to filter errors when no supported files found (matching OSS behavior) - Updated CHANGELOG with 2.18.1 fixes
1 parent 185ca1a commit 19c4658

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Snyk Security Changelog
22

3+
## [2.18.1]
4+
### Fixed
5+
- Fixed Agent Fix not applying edits for file paths containing spaces or special characters by properly handling URL-encoded URIs in workspace edit operations
6+
- Fixed inconsistent error handling in tree node text: OSS now checks for errors before scanning status (matching IAC and Code Security behavior)
7+
- Fixed IAC error display to filter out errors when no supported files are found, matching OSS behavior
38
## [2.18.0]
49
### Changed
510
- Added organization configuration at project level

src/main/kotlin/io/snyk/plugin/ui/toolwindow/SnykToolWindowPanel.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,19 @@ class SnykToolWindowPanel(
510510
) {
511511
val settings = pluginSettings()
512512

513-
val realError =
513+
val realOssError =
514514
getSnykCachedResults(project)?.currentOssError != null && ossResultsCount != NODE_NOT_SUPPORTED_STATE
515+
val realIacError =
516+
getSnykCachedResults(project)?.currentIacError != null && iacResultsCount != NODE_NOT_SUPPORTED_STATE
515517

516-
val newOssTreeNodeText = getNewOssTreeNodeText(settings, realError, ossResultsCount, addHMLPostfix)
518+
val newOssTreeNodeText = getNewOssTreeNodeText(settings, realOssError, ossResultsCount, addHMLPostfix)
517519
newOssTreeNodeText?.let { rootOssTreeNode.userObject = it }
518520

519521
val newSecurityIssuesNodeText =
520522
getNewSecurityIssuesNodeText(settings, securityIssuesCount, addHMLPostfix)
521523
newSecurityIssuesNodeText?.let { rootSecurityIssuesTreeNode.userObject = it }
522524

523-
val newIacTreeNodeText = getNewIacTreeNodeText(settings, iacResultsCount, addHMLPostfix)
525+
val newIacTreeNodeText = getNewIacTreeNodeText(settings, realIacError, iacResultsCount, addHMLPostfix)
524526
newIacTreeNodeText?.let { rootIacIssuesTreeNode.userObject = it }
525527

526528
val newRootTreeNodeText = getNewRootTreeNodeText()
@@ -538,11 +540,12 @@ class SnykToolWindowPanel(
538540

539541
private fun getNewIacTreeNodeText(
540542
settings: SnykApplicationSettingsStateService,
543+
realError: Boolean,
541544
iacResultsCount: Int?,
542545
addHMLPostfix: String
543546
) = when {
544-
getSnykCachedResults(project)?.currentIacError != null -> {
545-
val errorSuffix = getSnykCachedResults(project)!!.currentSnykCodeError!!.treeNodeSuffix
547+
realError -> {
548+
val errorSuffix = getSnykCachedResults(project)!!.currentIacError!!.treeNodeSuffix
546549
"$IAC_ROOT_TEXT $errorSuffix"
547550
}
548551
isIacRunning(project) && settings.iacScanEnabled -> "$IAC_ROOT_TEXT (scanning...)"
@@ -589,11 +592,11 @@ class SnykToolWindowPanel(
589592
ossResultsCount: Int?,
590593
addHMLPostfix: String
591594
) = when {
592-
isOssRunning(project) && settings.ossScanEnable -> "$OSS_ROOT_TEXT (scanning...)"
593595
realError -> {
594-
val errorSuffix = getSnykCachedResults(project)!!.currentSnykCodeError!!.treeNodeSuffix
596+
val errorSuffix = getSnykCachedResults(project)!!.currentOssError!!.treeNodeSuffix
595597
"$OSS_ROOT_TEXT $errorSuffix"
596598
}
599+
isOssRunning(project) && settings.ossScanEnable -> "$OSS_ROOT_TEXT (scanning...)"
597600

598601
else ->
599602
ossResultsCount?.let { count ->

0 commit comments

Comments
 (0)