Skip to content

Commit 9ba2186

Browse files
authored
Fix panic in auto-completion handler for bundle run/open (#3358)
## Why Regression introduced in #3175 / version 0.259.0. Fixes #3338 ## Tests New acceptance tests that trigger completion handler for bundle/open.
1 parent 0437317 commit 9ba2186

File tree

7 files changed

+25
-0
lines changed

7 files changed

+25
-0
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
* Show "DEFAULT" as the default profile for `databricks auth login` [#3252](https://github.com/databricks/cli/pull/3252)
1111

1212
### Bundles
13+
* Fix panic in auto competion handler for bundler run/open. Regression introduced in 0.259.0.
1314

1415
### API Changes

acceptance/bundle/open/output.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ Opening browser at [DATABRICKS_URL]/jobs/[NUMID]?o=[NUMID]
2424
Error: exec: "open": cannot run executable found relative to current directory
2525

2626
Exit code (musterr): 1
27+
28+
=== test auto-completion handler
29+
>>> [CLI] __complete bundle open ,
30+
foo
31+
:4
32+
Completion ended with directive: ShellCompDirectiveNoFileComp

acceptance/bundle/open/script

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ export PATH=.:$PATH
1111

1212
title "open after deployment. This will fail to open browser and complain, that's ok, we only want the message"
1313
musterr trace $CLI bundle open foo
14+
15+
title "test auto-completion handler"
16+
trace $CLI __complete bundle open ,

acceptance/bundle/run/basic/output.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ Run URL: [DATABRICKS_URL]/job/run/[NUMID]
3232
=== inline script
3333
>>> [CLI] bundle run -- echo hello
3434
hello
35+
36+
=== completion handler
37+
>>> [CLI] __complete bundle run ,
38+
foo
39+
:4
40+
Completion ended with directive: ShellCompDirectiveNoFileComp

acceptance/bundle/run/basic/script

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ errcode trace $CLI bundle run foo -- arg1 arg2
1414

1515
title "inline script"
1616
errcode trace $CLI bundle run -- echo "hello"
17+
18+
title "completion handler"
19+
trace $CLI __complete bundle run ,

cmd/bundle/open.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ func newOpenCommand() *cobra.Command {
134134
}
135135

136136
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
137+
ctx := logdiag.InitContext(cmd.Context())
138+
cmd.SetContext(ctx)
139+
137140
b := root.MustConfigureBundle(cmd)
138141
if logdiag.HasError(cmd.Context()) {
139142
return nil, cobra.ShellCompDirectiveError

cmd/bundle/run.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ Example usage:
225225
}
226226

227227
cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
228+
ctx := logdiag.InitContext(cmd.Context())
229+
cmd.SetContext(ctx)
230+
228231
b := root.MustConfigureBundle(cmd)
229232
if logdiag.HasError(cmd.Context()) {
230233
return nil, cobra.ShellCompDirectiveError

0 commit comments

Comments
 (0)