Skip to content

Commit 031c406

Browse files
authored
Fixed bundle init not working on Standard tier (#3496)
## Changes Fixed bundle init not working on Standard tier Now handling FEATURE_DISABLED error correctly in `default_catalog` hekper function ## Why Fixes #3472 ## Tests Added acceptance test <!-- 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 2a0d461 commit 031c406

File tree

7 files changed

+38
-1
lines changed

7 files changed

+38
-1
lines changed

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ See more details here: ([#3225](https://github.com/databricks/cli/pull/3225))
1818
* [Breaking Change] Remove deprecated path fallback mechanism for jobs and pipelines ([#3225](https://github.com/databricks/cli/pull/3225))
1919
* Add support for Lakebase synced database tables in DABs ([#3467](https://github.com/databricks/cli/pull/3467))
2020
* Rename Delta Live Tables to Lakeflow Declarative Pipelines in the default-python template ([#3476](https://github.com/databricks/cli/pull/3476)).
21+
* Fixed bundle init not working on Standard tier ([#3496](https://github.com/databricks/cli/pull/3496))
2122

2223
### API Changes
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"project_name": "my_default_python",
3+
"include_notebook": "yes",
4+
"include_dlt": "yes",
5+
"include_python": "yes",
6+
"serverless": "no"
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
>>> [CLI] bundle init default-python --config-file ./input.json --output-dir output
3+
4+
Welcome to the default Python template for Databricks Asset Bundles!
5+
Workspace to use (auto-detected, edit in 'my_default_python/databricks.yml'): [DATABRICKS_URL]
6+
7+
✨ Your new project has been created in the 'my_default_python' directory!
8+
9+
Please refer to the README.md file for "getting started" instructions.
10+
See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
trace $CLI bundle init default-python --config-file ./input.json --output-dir output
2+
3+
rm -rf output
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[[Server]]
2+
Pattern = "GET /api/2.1/unity-catalog/current-metastore-assignment"
3+
Response.StatusCode = 404
4+
Response.Body = "{\"error_code\": \"FEATURE_DISABLED\", \"message\": \"Unity Catalog is not available for feature tier STANDARD_TIER.\"}"

libs/template/helpers.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/url"
99
"os"
1010
"regexp"
11+
"slices"
1112
"strings"
1213
"text/template"
1314

@@ -38,6 +39,12 @@ var (
3839
cachedCatalog *string
3940
)
4041

42+
var metastoreDisabledErrorCodes = []string{
43+
"PERMISSION_DENIED",
44+
"METASTORE_DOES_NOT_EXIST", // Default metastore is not assigned to the workspace.
45+
"FEATURE_DISABLED", // Unity Catalog is not available for feature tier STANDARD_TIER.
46+
}
47+
4148
// UUID that is stable for the duration of the template execution. This can be used
4249
// to populate the `bundle.uuid` field in databricks.yml by template authors.
4350
//
@@ -141,7 +148,7 @@ func loadHelpers(ctx context.Context) template.FuncMap {
141148
metastore, err := w.Metastores.Current(ctx)
142149
if err != nil {
143150
var aerr *apierr.APIError
144-
if errors.As(err, &aerr) && (aerr.ErrorCode == "PERMISSION_DENIED" || aerr.ErrorCode == "METASTORE_DOES_NOT_EXIST") {
151+
if errors.As(err, &aerr) && slices.Contains(metastoreDisabledErrorCodes, aerr.ErrorCode) {
145152
// Ignore: access denied or workspace doesn't have a metastore assigned
146153
empty_default := ""
147154
cachedCatalog = &empty_default

0 commit comments

Comments
 (0)