Skip to content

Commit fdc83a3

Browse files
committed
fix: handle null xray scan results with try() function
Adds proper null handling for cases where xray scan results are null, which was causing Terraform validation failures. Uses try() function to gracefully handle null values and provide default vulnerability counts.
1 parent a72c36e commit fdc83a3

File tree

1 file changed

+15
-7
lines changed
  • registry/coder/modules/jfrog-xray

1 file changed

+15
-7
lines changed

registry/coder/modules/jfrog-xray/main.tf

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,21 @@ data "xray_artifacts_scan" "image_scan" {
8282

8383
# Extract vulnerability counts
8484
locals {
85-
vulnerabilities = length(data.xray_artifacts_scan.image_scan.results) > 0 ? data.xray_artifacts_scan.image_scan.results[0].sec_issues : {
86-
critical = 0
87-
high = 0
88-
medium = 0
89-
low = 0
90-
}
91-
85+
vulnerabilities = try(
86+
length(data.xray_artifacts_scan.image_scan.results) > 0 ? data.xray_artifacts_scan.image_scan.results[0].sec_issues : {
87+
critical = 0
88+
high = 0
89+
medium = 0
90+
low = 0
91+
},
92+
{
93+
critical = 0
94+
high = 0
95+
medium = 0
96+
low = 0
97+
}
98+
)
99+
92100
total_vulnerabilities = local.vulnerabilities.critical + local.vulnerabilities.high + local.vulnerabilities.medium + local.vulnerabilities.low
93101
}
94102

0 commit comments

Comments
 (0)