From 5b7791fdc388310f0d7376fb1f5c21830735c2ad Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Fri, 25 Apr 2025 12:27:35 +0200 Subject: [PATCH] Fix nil crash in normalize_paths.go --- .../empty_resources/empty_dict/output.txt | 14 ++++++-------- .../bundle/validate/empty_resources/test.toml | 5 ----- .../empty_resources/with_grants/output.txt | 16 +++++++++------- .../empty_resources/with_permissions/output.txt | 16 ++++++++-------- bundle/config/mutator/normalize_paths.go | 3 +++ 5 files changed, 26 insertions(+), 28 deletions(-) delete mode 100644 acceptance/bundle/validate/empty_resources/test.toml diff --git a/acceptance/bundle/validate/empty_resources/empty_dict/output.txt b/acceptance/bundle/validate/empty_resources/empty_dict/output.txt index 86f9bd0233c..b650b9502f6 100644 --- a/acceptance/bundle/validate/empty_resources/empty_dict/output.txt +++ b/acceptance/bundle/validate/empty_resources/empty_dict/output.txt @@ -1,14 +1,12 @@ === resources.jobs.rname === -The Databricks CLI unexpectedly had a fatal error. -Please report this issue to Databricks in the form of a GitHub issue at: -https://github.com/databricks/cli +Error: job rname is not defined -CLI Version: [DEV_VERSION] - -Panic Payload: runtime error: invalid memory address or nil pointer dereference - - +{ + "jobs": { + "rname": {} + } +} === resources.pipelines.rname === Error: pipeline rname is not defined diff --git a/acceptance/bundle/validate/empty_resources/test.toml b/acceptance/bundle/validate/empty_resources/test.toml deleted file mode 100644 index 3bc1fecf89e..00000000000 --- a/acceptance/bundle/validate/empty_resources/test.toml +++ /dev/null @@ -1,5 +0,0 @@ -Badness = "One of the tests for jobs crashes" - -[[Repls]] -Old = '(?s)Stack Trace:.*?\n\n' -New = "\n\n" diff --git a/acceptance/bundle/validate/empty_resources/with_grants/output.txt b/acceptance/bundle/validate/empty_resources/with_grants/output.txt index a6a441bace6..e91661e29df 100644 --- a/acceptance/bundle/validate/empty_resources/with_grants/output.txt +++ b/acceptance/bundle/validate/empty_resources/with_grants/output.txt @@ -1,14 +1,16 @@ === resources.jobs.rname === -The Databricks CLI unexpectedly had a fatal error. -Please report this issue to Databricks in the form of a GitHub issue at: -https://github.com/databricks/cli - -CLI Version: [DEV_VERSION] +Warning: unknown field: grants + at resources.jobs.rname + in databricks.yml:7:7 -Panic Payload: runtime error: invalid memory address or nil pointer dereference +Error: job rname is not defined - +{ + "jobs": { + "rname": {} + } +} === resources.pipelines.rname === Warning: unknown field: grants diff --git a/acceptance/bundle/validate/empty_resources/with_permissions/output.txt b/acceptance/bundle/validate/empty_resources/with_permissions/output.txt index cf9215980d0..718ede2ba38 100644 --- a/acceptance/bundle/validate/empty_resources/with_permissions/output.txt +++ b/acceptance/bundle/validate/empty_resources/with_permissions/output.txt @@ -1,14 +1,14 @@ === resources.jobs.rname === -The Databricks CLI unexpectedly had a fatal error. -Please report this issue to Databricks in the form of a GitHub issue at: -https://github.com/databricks/cli +Error: job rname is not defined -CLI Version: [DEV_VERSION] - -Panic Payload: runtime error: invalid memory address or nil pointer dereference - - +{ + "jobs": { + "rname": { + "permissions": [] + } + } +} === resources.pipelines.rname === Error: pipeline rname is not defined diff --git a/bundle/config/mutator/normalize_paths.go b/bundle/config/mutator/normalize_paths.go index 04675d59d28..3f4d5337c6c 100644 --- a/bundle/config/mutator/normalize_paths.go +++ b/bundle/config/mutator/normalize_paths.go @@ -72,6 +72,9 @@ func collectGitSourcePaths(b *bundle.Bundle) []dyn.Path { var jobs []dyn.Path for name, job := range b.Config.Resources.Jobs { + if job == nil || job.JobSettings == nil { + continue + } if job.GitSource != nil { jobs = append(jobs, dyn.NewPath(dyn.Key("resources"), dyn.Key("jobs"), dyn.Key(name))) }