Skip to content

Commit 70a01f2

Browse files
authored
Fixed panic in bundle generate command when multiple profiles matched (#3770)
## Changes Fixed panic in bundle generate command when multiple profiles matched ## Why Previously it would fail with ``` Error: cannot resolve bundle auth configuration: resolve: https://foobar.com: multiple profiles matched: deco-staging, deco-staging-2, deco-staging-sp: please set DATABRICKS_CONFIG_PROFILE or provide --profile flag to specify one. Config: host=https://foobar.com 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: 0.0.0-dev+5c95e650cc33 Panic Payload: cannot resolve bundle auth configuration: resolve: https://foobar.com: multiple profiles matched: deco-staging, deco-staging-2, deco-staging-sp: please set DATABRICKS_CONFIG_PROFILE or provide --profile flag to specify one. Config: host=https://foobar.com Stack Trace: goroutine 1 [running]: runtime/debug.Stack() /Users/andrew.nester/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:26 +0x64 github.com/databricks/cli/cmd/root.Execute.func1() /Users/andrew.nester/cli/cmd/root/root.go:112 +0x9c panic({0x105bd2da0?, 0x1400061fe80?}) /Users/andrew.nester/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:783 +0x120 github.com/databricks/cli/bundle.(*Bundle).WorkspaceClient(...) /Users/andrew.nester/cli/bundle/bundle.go:221 github.com/databricks/cli/cmd/bundle/generate.NewGenerateAppCommand.func1(0x140005b7b08, {0x1056fb433?, 0x4?, 0x1056fb437?}) /Users/andrew.nester/cli/cmd/bundle/generate/app.go:66 +0x590 github.com/spf13/cobra.(*Command).execute(0x140005b7b08, {0x140001248c0, 0x2, 0x2}) /Users/andrew.nester/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0x7d4 github.com/spf13/cobra.(*Command).ExecuteC(0x1400019ec08) /Users/andrew.nester/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x350 github.com/spf13/cobra.(*Command).ExecuteContextC(...) /Users/andrew.nester/go/pkg/mod/github.com/spf13/[email protected]/command.go:1080 github.com/databricks/cli/cmd/root.Execute({0x105ee2ce0, 0x106af60a0}, 0x1400019ec08) /Users/andrew.nester/cli/cmd/root/root.go:141 +0x108 main.main() /Users/andrew.nester/cli/main.go:29 +0x44 ``` Now with ``` Error: cannot resolve bundle auth configuration: resolve: foobar.com multiple profiles matched: deco-staging, deco-staging-2, deco-staging-sp: please set DATABRICKS_CONFIG_PROFILE or provide --profile flag to specify one. Config: host=foobar.com ``` ## Tests Manually tested <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 5ea3e06 commit 70a01f2

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

cmd/bundle/generate/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ per target environment.`,
5959
cmd.SetContext(ctx)
6060

6161
b := root.MustConfigureBundle(cmd)
62-
if b == nil {
62+
if b == nil || logdiag.HasError(ctx) {
6363
return root.ErrAlreadyPrinted
6464
}
6565

cmd/bundle/generate/dashboard.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ func (d *dashboard) RunE(cmd *cobra.Command, args []string) error {
389389
cmd.SetContext(ctx)
390390

391391
b := root.MustConfigureBundle(cmd)
392-
if b == nil {
392+
if b == nil || logdiag.HasError(ctx) {
393393
return root.ErrAlreadyPrinted
394394
}
395395

cmd/bundle/generate/job.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ After generation, you can deploy this job to other targets using:
6262
cmd.SetContext(ctx)
6363

6464
b := root.MustConfigureBundle(cmd)
65-
if b == nil {
65+
if b == nil || logdiag.HasError(ctx) {
6666
return root.ErrAlreadyPrinted
6767
}
6868

cmd/bundle/generate/pipeline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ like catalogs, schemas, and compute configurations per target.`,
6262
cmd.SetContext(ctx)
6363

6464
b := root.MustConfigureBundle(cmd)
65-
if b == nil {
65+
if b == nil || logdiag.HasError(ctx) {
6666
return root.ErrAlreadyPrinted
6767
}
6868

0 commit comments

Comments
 (0)