Skip to content

Commit 547f2c7

Browse files
authored
fix: guard against nil target entries in bundle debug list-targets (#5203)
## Summary - `bundle debug list-targets` panics with a nil pointer dereference at `cmd/bundle/debug/list_targets.go:40` when the targets map contains a nil `*config.Target`. - YAML decoding can leave such an entry when a target is declared with a null value; `collectTargets` then dereferences `t.Default`/`t.Mode` without a nil check. - Skip nil entries while still listing the target name so the command no longer crashes. ## Test plan - [ ] `./task test` passes. - [ ] Manual: a `databricks.yml` with a null-valued target lists its name and exits 0 instead of panicking.
1 parent c59058c commit 547f2c7

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
### Bundles
1111
* Validate that resource keys do not contain variable references ([#5169](https://github.com/databricks/cli/pull/5169))
1212
* engine/direct: Drop the deployment state entry on a recreate before the follow-up `Create`, so a `Create` failure no longer leaves a broken state with `invalid state: empty id` on the next `bundle plan` ([#5173](https://github.com/databricks/cli/pull/5173)).
13+
* `bundle debug list-targets`: skip nil entries in the targets map instead of panicking when a target is declared with a null value ([#5203](https://github.com/databricks/cli/pull/5203)).
1314

1415
### Dependency updates
1516

cmd/bundle/debug/list_targets.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ func collectTargets(targets map[string]*config.Target) []targetInfo {
3535
result := make([]targetInfo, 0, len(names))
3636
for _, name := range names {
3737
t := targets[name]
38+
// YAML decoding can leave a nil entry in the map when a target is
39+
// declared with a null value. Skip rather than dereference and panic.
40+
if t == nil {
41+
result = append(result, targetInfo{Name: name})
42+
continue
43+
}
3844
info := targetInfo{
3945
Name: name,
4046
Default: t.Default,

0 commit comments

Comments
 (0)