diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index d6b5dde4f9..27c922279d 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -18,5 +18,6 @@ See more details here: ([#3225](https://github.com/databricks/cli/pull/3225)) * [Breaking Change] Remove deprecated path fallback mechanism for jobs and pipelines ([#3225](https://github.com/databricks/cli/pull/3225)) * Add support for Lakebase synced database tables in DABs ([#3467](https://github.com/databricks/cli/pull/3467)) * Rename Delta Live Tables to Lakeflow Declarative Pipelines in the default-python template ([#3476](https://github.com/databricks/cli/pull/3476)). +* Fixed bundle init not working on Standard tier ([#3496](https://github.com/databricks/cli/pull/3496)) ### API Changes diff --git a/acceptance/bundle/templates/default-python/no-uc/input.json b/acceptance/bundle/templates/default-python/no-uc/input.json new file mode 100644 index 0000000000..2c4416c00c --- /dev/null +++ b/acceptance/bundle/templates/default-python/no-uc/input.json @@ -0,0 +1,7 @@ +{ + "project_name": "my_default_python", + "include_notebook": "yes", + "include_dlt": "yes", + "include_python": "yes", + "serverless": "no" +} diff --git a/acceptance/bundle/templates/default-python/no-uc/out.test.toml b/acceptance/bundle/templates/default-python/no-uc/out.test.toml new file mode 100644 index 0000000000..8f3575be7b --- /dev/null +++ b/acceptance/bundle/templates/default-python/no-uc/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"] diff --git a/acceptance/bundle/templates/default-python/no-uc/output.txt b/acceptance/bundle/templates/default-python/no-uc/output.txt new file mode 100644 index 0000000000..6abf52cf09 --- /dev/null +++ b/acceptance/bundle/templates/default-python/no-uc/output.txt @@ -0,0 +1,10 @@ + +>>> [CLI] bundle init default-python --config-file ./input.json --output-dir output + +Welcome to the default Python template for Databricks Asset Bundles! +Workspace to use (auto-detected, edit in 'my_default_python/databricks.yml'): [DATABRICKS_URL] + +✨ Your new project has been created in the 'my_default_python' directory! + +Please refer to the README.md file for "getting started" instructions. +See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. diff --git a/acceptance/bundle/templates/default-python/no-uc/script b/acceptance/bundle/templates/default-python/no-uc/script new file mode 100644 index 0000000000..d6195ee17b --- /dev/null +++ b/acceptance/bundle/templates/default-python/no-uc/script @@ -0,0 +1,3 @@ +trace $CLI bundle init default-python --config-file ./input.json --output-dir output + +rm -rf output diff --git a/acceptance/bundle/templates/default-python/no-uc/test.toml b/acceptance/bundle/templates/default-python/no-uc/test.toml new file mode 100644 index 0000000000..3f795d5c48 --- /dev/null +++ b/acceptance/bundle/templates/default-python/no-uc/test.toml @@ -0,0 +1,4 @@ +[[Server]] +Pattern = "GET /api/2.1/unity-catalog/current-metastore-assignment" +Response.StatusCode = 404 +Response.Body = "{\"error_code\": \"FEATURE_DISABLED\", \"message\": \"Unity Catalog is not available for feature tier STANDARD_TIER.\"}" diff --git a/libs/template/helpers.go b/libs/template/helpers.go index c258775a43..27bb0d0432 100644 --- a/libs/template/helpers.go +++ b/libs/template/helpers.go @@ -8,6 +8,7 @@ import ( "net/url" "os" "regexp" + "slices" "strings" "text/template" @@ -38,6 +39,12 @@ var ( cachedCatalog *string ) +var metastoreDisabledErrorCodes = []string{ + "PERMISSION_DENIED", + "METASTORE_DOES_NOT_EXIST", // Default metastore is not assigned to the workspace. + "FEATURE_DISABLED", // Unity Catalog is not available for feature tier STANDARD_TIER. +} + // UUID that is stable for the duration of the template execution. This can be used // to populate the `bundle.uuid` field in databricks.yml by template authors. // @@ -141,7 +148,7 @@ func loadHelpers(ctx context.Context) template.FuncMap { metastore, err := w.Metastores.Current(ctx) if err != nil { var aerr *apierr.APIError - if errors.As(err, &aerr) && (aerr.ErrorCode == "PERMISSION_DENIED" || aerr.ErrorCode == "METASTORE_DOES_NOT_EXIST") { + if errors.As(err, &aerr) && slices.Contains(metastoreDisabledErrorCodes, aerr.ErrorCode) { // Ignore: access denied or workspace doesn't have a metastore assigned empty_default := "" cachedCatalog = &empty_default