From b4772557524d763857cb51ac27b09859da20474d Mon Sep 17 00:00:00 2001 From: Bailey Brownie Date: Wed, 14 Jan 2026 22:27:28 -0500 Subject: [PATCH 1/3] Fix bundle init not working in Azure Government --- .../default-python/azure-government/input.json | 7 +++++++ .../default-python/azure-government/out.test.toml | 5 +++++ .../default-python/azure-government/output.txt | 13 +++++++++++++ .../default-python/azure-government/script | 3 +++ .../default-python/azure-government/test.toml | 4 ++++ libs/template/helpers.go | 2 +- 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 acceptance/bundle/templates/default-python/azure-government/input.json create mode 100644 acceptance/bundle/templates/default-python/azure-government/out.test.toml create mode 100644 acceptance/bundle/templates/default-python/azure-government/output.txt create mode 100644 acceptance/bundle/templates/default-python/azure-government/script create mode 100644 acceptance/bundle/templates/default-python/azure-government/test.toml diff --git a/acceptance/bundle/templates/default-python/azure-government/input.json b/acceptance/bundle/templates/default-python/azure-government/input.json new file mode 100644 index 0000000000..2c4416c00c --- /dev/null +++ b/acceptance/bundle/templates/default-python/azure-government/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/azure-government/out.test.toml b/acceptance/bundle/templates/default-python/azure-government/out.test.toml new file mode 100644 index 0000000000..d560f1de04 --- /dev/null +++ b/acceptance/bundle/templates/default-python/azure-government/out.test.toml @@ -0,0 +1,5 @@ +Local = true +Cloud = false + +[EnvMatrix] + DATABRICKS_BUNDLE_ENGINE = ["terraform", "direct"] diff --git a/acceptance/bundle/templates/default-python/azure-government/output.txt b/acceptance/bundle/templates/default-python/azure-government/output.txt new file mode 100644 index 0000000000..4c34df71ef --- /dev/null +++ b/acceptance/bundle/templates/default-python/azure-government/output.txt @@ -0,0 +1,13 @@ + +>>> [CLI] bundle init default-python --config-file ./input.json --output-dir output +Welcome to the default Python template for Databricks Asset Bundles! + +Answer the following questions to customize your project. +You can always change your configuration in the databricks.yml file later. + +Note that [DATABRICKS_URL] is used for initialization. +(For information on how to change your profile, see https://docs.databricks.com/dev-tools/cli/profiles.html.) + +✨ Your new project has been created in the 'my_default_python' directory! + +To get started, refer to the project README.md file and the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. diff --git a/acceptance/bundle/templates/default-python/azure-government/script b/acceptance/bundle/templates/default-python/azure-government/script new file mode 100644 index 0000000000..d6195ee17b --- /dev/null +++ b/acceptance/bundle/templates/default-python/azure-government/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/azure-government/test.toml b/acceptance/bundle/templates/default-python/azure-government/test.toml new file mode 100644 index 0000000000..d62040a506 --- /dev/null +++ b/acceptance/bundle/templates/default-python/azure-government/test.toml @@ -0,0 +1,4 @@ +[[Server]] +Pattern = "GET /api/2.1/unity-catalog/current-metastore-assignment" +Response.StatusCode = 404 +Response.Body = "{ \"error\": \"Bad Target: /api/2.1/unity-catalog/current-metastore-assignment\" }" diff --git a/libs/template/helpers.go b/libs/template/helpers.go index 27bb0d0432..7abf6e0756 100644 --- a/libs/template/helpers.go +++ b/libs/template/helpers.go @@ -148,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) && slices.Contains(metastoreDisabledErrorCodes, aerr.ErrorCode) { + if errors.As(err, &aerr) && (slices.Contains(metastoreDisabledErrorCodes, aerr.ErrorCode) || aerr.Message == "Bad Target: /api/2.1/unity-catalog/current-metastore-assignment") { // Ignore: access denied or workspace doesn't have a metastore assigned empty_default := "" cachedCatalog = &empty_default From 1477aff12adac3af8425d61b338c48391a66259d Mon Sep 17 00:00:00 2001 From: Bailey Brownie Date: Wed, 14 Jan 2026 22:49:43 -0500 Subject: [PATCH 2/3] Add fix to changelog --- NEXT_CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 97fe7d96df..64041b66a5 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -10,4 +10,7 @@ ### Dependency updates +### Bundles +* Fix bundle init not working in Azure Government ([#4286](https://github.com/databricks/cli/pull/4286) + ### API Changes From b24d4c1acd00efd3907be85a8cf0fae3b80a3ff7 Mon Sep 17 00:00:00 2001 From: Bailey Brownie Date: Wed, 14 Jan 2026 22:51:32 -0500 Subject: [PATCH 3/3] Update changelog message --- NEXT_CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 64041b66a5..81d9318707 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -11,6 +11,6 @@ ### Dependency updates ### Bundles -* Fix bundle init not working in Azure Government ([#4286](https://github.com/databricks/cli/pull/4286) +* Fix bundle init not working in Azure Government ([#4286](https://github.com/databricks/cli/pull/4286)) ### API Changes