Skip to content

Commit fbea96d

Browse files
authored
Fix nil crash when job has no fields defined (#2776)
## Changes Add missing nil checks in normalize_paths.go ## Tests Tests added previously in #2771 and #2774
1 parent 3ee69c8 commit fbea96d

5 files changed

Lines changed: 26 additions & 28 deletions

File tree

acceptance/bundle/validate/empty_resources/empty_dict/output.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11

22
=== resources.jobs.rname ===
3-
The Databricks CLI unexpectedly had a fatal error.
4-
Please report this issue to Databricks in the form of a GitHub issue at:
5-
https://github.com/databricks/cli
3+
Error: job rname is not defined
64

7-
CLI Version: [DEV_VERSION]
8-
9-
Panic Payload: runtime error: invalid memory address or nil pointer dereference
10-
11-
<Stack Trace>
5+
{
6+
"jobs": {
7+
"rname": {}
8+
}
9+
}
1210

1311
=== resources.pipelines.rname ===
1412
Error: pipeline rname is not defined

acceptance/bundle/validate/empty_resources/test.toml

Lines changed: 0 additions & 5 deletions
This file was deleted.

acceptance/bundle/validate/empty_resources/with_grants/output.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11

22
=== resources.jobs.rname ===
3-
The Databricks CLI unexpectedly had a fatal error.
4-
Please report this issue to Databricks in the form of a GitHub issue at:
5-
https://github.com/databricks/cli
6-
7-
CLI Version: [DEV_VERSION]
3+
Warning: unknown field: grants
4+
at resources.jobs.rname
5+
in databricks.yml:7:7
86

9-
Panic Payload: runtime error: invalid memory address or nil pointer dereference
7+
Error: job rname is not defined
108

11-
<Stack Trace>
9+
{
10+
"jobs": {
11+
"rname": {}
12+
}
13+
}
1214

1315
=== resources.pipelines.rname ===
1416
Warning: unknown field: grants

acceptance/bundle/validate/empty_resources/with_permissions/output.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
=== resources.jobs.rname ===
3-
The Databricks CLI unexpectedly had a fatal error.
4-
Please report this issue to Databricks in the form of a GitHub issue at:
5-
https://github.com/databricks/cli
3+
Error: job rname is not defined
64

7-
CLI Version: [DEV_VERSION]
8-
9-
Panic Payload: runtime error: invalid memory address or nil pointer dereference
10-
11-
<Stack Trace>
5+
{
6+
"jobs": {
7+
"rname": {
8+
"permissions": []
9+
}
10+
}
11+
}
1212

1313
=== resources.pipelines.rname ===
1414
Error: pipeline rname is not defined

bundle/config/mutator/normalize_paths.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func collectGitSourcePaths(b *bundle.Bundle) []dyn.Path {
7272
var jobs []dyn.Path
7373

7474
for name, job := range b.Config.Resources.Jobs {
75+
if job == nil || job.JobSettings == nil {
76+
continue
77+
}
7578
if job.GitSource != nil {
7679
jobs = append(jobs, dyn.NewPath(dyn.Key("resources"), dyn.Key("jobs"), dyn.Key(name)))
7780
}

0 commit comments

Comments
 (0)