diff --git a/.nextchanges/bundles/notebook-path-with-colon.md b/.nextchanges/bundles/notebook-path-with-colon.md new file mode 100644 index 00000000000..6861009f876 --- /dev/null +++ b/.nextchanges/bundles/notebook-path-with-colon.md @@ -0,0 +1 @@ +* Fix bundle commands failing on a notebook or file path with a colon in its first segment, such as the default workspace notebook name `New Notebook 2026-10-28 12:17:43.ipynb`. ([#7851](https://github.com/databricks/cli/pull/7851)) diff --git a/acceptance/bundle/paths/notebook_name_with_colon/databricks.yml b/acceptance/bundle/paths/notebook_name_with_colon/databricks.yml new file mode 100644 index 00000000000..499f2635b87 --- /dev/null +++ b/acceptance/bundle/paths/notebook_name_with_colon/databricks.yml @@ -0,0 +1,11 @@ +bundle: + name: notebook_name_with_colon + +resources: + jobs: + job: + name: job + tasks: + - task_key: task + notebook_task: + notebook_path: New Notebook 12:17:43.ipynb diff --git a/acceptance/bundle/paths/notebook_name_with_colon/out.test.toml b/acceptance/bundle/paths/notebook_name_with_colon/out.test.toml new file mode 100644 index 00000000000..8c2cb31de53 --- /dev/null +++ b/acceptance/bundle/paths/notebook_name_with_colon/out.test.toml @@ -0,0 +1,3 @@ +Cloud = false +GOOS.windows = false +EnvMatrix.DMS = ["", "true"] diff --git a/acceptance/bundle/paths/notebook_name_with_colon/output.txt b/acceptance/bundle/paths/notebook_name_with_colon/output.txt new file mode 100644 index 00000000000..b8e9d0339fe --- /dev/null +++ b/acceptance/bundle/paths/notebook_name_with_colon/output.txt @@ -0,0 +1,3 @@ + +>>> [CLI] bundle validate -o json +"/Workspace/Users/[USERNAME]/.bundle/notebook_name_with_colon/default/files/New Notebook 12:17:43" diff --git a/acceptance/bundle/paths/notebook_name_with_colon/script b/acceptance/bundle/paths/notebook_name_with_colon/script new file mode 100644 index 00000000000..b1066878cd2 --- /dev/null +++ b/acceptance/bundle/paths/notebook_name_with_colon/script @@ -0,0 +1,4 @@ +# Windows does not allow colons in file names, so the notebook is not committed. +echo '{"cells": [], "metadata": {}, "nbformat": 4, "nbformat_minor": 0}' > "New Notebook 12:17:43.ipynb" +trace $CLI bundle validate -o json | jq '.resources.jobs.job.tasks[0].notebook_task.notebook_path' +rm "New Notebook 12:17:43.ipynb" diff --git a/acceptance/bundle/paths/notebook_name_with_colon/test.toml b/acceptance/bundle/paths/notebook_name_with_colon/test.toml new file mode 100644 index 00000000000..51e801776e4 --- /dev/null +++ b/acceptance/bundle/paths/notebook_name_with_colon/test.toml @@ -0,0 +1 @@ +GOOS.windows = false diff --git a/bundle/config/mutator/normalize_paths.go b/bundle/config/mutator/normalize_paths.go index 7256ebad4b7..2835e4b4f24 100644 --- a/bundle/config/mutator/normalize_paths.go +++ b/bundle/config/mutator/normalize_paths.go @@ -101,13 +101,9 @@ func normalizePath(path string, location diag.Location, bundleRootPath string) ( } } - pathAsUrl, err := url.Parse(path) - if err != nil { - return "", err - } - - // if path has scheme, it's a full path and doesn't need to be relativized - if pathAsUrl.Scheme != "" { + // if path has scheme, it's a full path and doesn't need to be relativized. + // A path that is not a valid URL, such as "New Notebook 12:17:43.ipynb", is a local path. + if pathAsUrl, err := url.Parse(path); err == nil && pathAsUrl.Scheme != "" { return path, nil } diff --git a/bundle/config/mutator/translate_paths.go b/bundle/config/mutator/translate_paths.go index ad695e56643..68fb913ada1 100644 --- a/bundle/config/mutator/translate_paths.go +++ b/bundle/config/mutator/translate_paths.go @@ -130,13 +130,9 @@ func (t *translateContext) rewritePath( return "", nil } - url, err := url.Parse(input) - if err != nil { - return "", err - } - - // If the file path has scheme, it's a full path and we don't need to transform it - if url.Scheme != "" { + // If the file path has scheme, it's a full path and we don't need to transform it. + // A path that is not a valid URL, such as "New Notebook 12:17:43.ipynb", is a local path. + if u, err := url.Parse(input); err == nil && u.Scheme != "" { return "", nil }