Skip to content

Print forward-slash paths in error messages on Windows - #7377

Open
denik wants to merge 3 commits into
mainfrom
windows-toslash-cleanup
Open

denik wants to merge 3 commits into
mainfrom
windows-toslash-cleanup

Conversation

@denik

@denik denik commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Changes

Wrap local paths with filepath.ToSlash in user-facing messages: diagnostic locations (diag.Location.String, which covers YAML/JSON load errors), config load/rewrite errors, variable-overrides file errors, artifact glob errors, duplicate library names, the bundle-root glob check, the sync-root check, the git repository-root check and filer errors. acceptance/bin/diff.py now prints POSIX paths too.

Remove the backslash Repls from acceptance tests that no longer need them. Some were already stale (docker host, apps/init, genie_space generate, integration_whl/serverless*, overrides_file_complex_path, nil_artifacts, wrong-url).

Why

This is a follow-up to #4528. Output is the same on every OS, so tests don't need per-test separator fixups.

Tests

Linux outputs are unchanged. The Windows cell runs the changed tests. Cases left out on purpose are listed in a comment below.

This pull request and its description were written by Isaac.

Convert local paths to forward slashes with filepath.ToSlash in user-facing
messages (diagnostic locations, YAML/JSON load errors, variable overrides file
errors, glob errors, duplicate library names, sync root errors, git root errors,
filer errors) and in diff.py output. Remove acceptance Repls that normalized
backslashes and are no longer needed.

Co-authored-by: Isaac <no-reply@databricks.com>
@denik
denik requested review from a team as code owners November 5, 2026 11:26
Co-authored-by: Isaac <no-reply@databricks.com>
@denik

denik commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

Cases left out of this PR (risky or not CLI output):

  • Artifact paths in bundle validate -o json ('\\\\' Repls in artifacts/artifacts_dynamic_version, build_and_files, glob_exact_whl, globs_in_files, globs_in_files_in_include, globs_invalid, whl_dynamic, integration_whl/serverless_extras_dynamic_version, templates/default-python/integration_classic, resources/clusters/run/spark_python_task). artifacts.*.path, files[].source and patched hold native absolute paths in the config, and filepath.Glob/filepath.Rel use them. One example: the matches[0] == source check in bundle/artifacts/expand_globs.go would stop matching on Windows if source used forward slashes. Fixing this changes internal state, not just display, so it needs its own PR.
  • bundle/run/inline-script/cwd: the path is printed by python's os.getcwd(), not by the CLI.
  • templates/default-python/combinations: cloud-only, and it's not clear which output has the backslash.
  • Not path separators: selftest/basic (tests the Repl mechanism itself), the telemetry \\" Repls, genie_spaces/change-serialized-space (\r\n), inline-script/basic (\$PATH).

I removed Repls from a few cloud-only tests based on reading the code: cmd/fs/cp/file-to-nonexistent-dir, bundle/generate/genie_space, integration_whl/serverless, integration_whl/serverless_dynamic_version. PR CI can't check these on Windows.

@github-actions github-actions Bot added the DABs DABs related issues label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Commit: 342aff244 | Workflow run

Regression test report

Selected 20 changed tests (limit=20, 2 not selected)

36 tests: regression=0 unreleased=0 coverage=36 failing=0
test branch main (5c0ab45) latest (v1.24.0)
TestAccept/apps/init/auth-mode ✅ ✅ ✅
TestAccept/apps/init/binding-values ✅ ✅ ✅
TestAccept/bundle/artifacts/globs_in_files/DMS= ✅ ✅ ✅
TestAccept/bundle/artifacts/globs_in_files/DMS=true ✅ ✅ ✅
TestAccept/bundle/artifacts/globs_invalid/DMS= ✅ ✅ ✅
TestAccept/bundle/artifacts/globs_invalid/DMS=true ✅ ✅ ✅
TestAccept/bundle/artifacts/nil_artifacts/DMS= ✅ ✅ ✅
TestAccept/bundle/artifacts/nil_artifacts/DMS=true ✅ ✅ ✅
TestAccept/bundle/artifacts/same_name_libraries/DMS= ✅ ✅ ✅
TestAccept/bundle/artifacts/same_name_libraries/DMS=true ✅ ✅ ✅
TestAccept/bundle/deploy/mlops-stacks/DMS= ✅ ✅ ✅
TestAccept/bundle/deploy/mlops-stacks/DMS=true ✅ ✅ ✅
TestAccept/bundle/generate/genie_space/DMS= ✅ ✅ ✅
TestAccept/bundle/generate/genie_space/DMS=true ✅ ✅ ✅
TestAccept/bundle/includes/glob_in_root_path/DMS= ✅ ✅ ✅
TestAccept/bundle/includes/glob_in_root_path/DMS=true ✅ ✅ ✅
TestAccept/bundle/integration_whl/serverless/DMS= ✅ ✅ ✅
TestAccept/bundle/integration_whl/serverless/DMS=true ✅ ✅ ✅
TestAccept/bundle/integration_whl/serverless_dynamic_version/DMS= ✅ ✅ ✅
TestAccept/bundle/integration_whl/serverless_dynamic_version/DMS=true ✅ ✅ ✅
TestAccept/bundle/paths/outside_root_no_sync/DMS= ✅ ✅ ✅
TestAccept/bundle/paths/outside_root_no_sync/DMS=true ✅ ✅ ✅
TestAccept/bundle/paths/pipelines_root_path_outside_sync_root/DMS= ✅ ✅ ✅
TestAccept/bundle/paths/pipelines_root_path_outside_sync_root/DMS=true ✅ ✅ ✅
TestAccept/bundle/syncroot/dotdot-git/DMS= ✅ ✅ ✅
TestAccept/bundle/syncroot/dotdot-git/DMS=true ✅ ✅ ✅
TestAccept/bundle/templates-machinery/wrong-url/DMS= ✅ ✅ ✅
TestAccept/bundle/templates-machinery/wrong-url/DMS=true ✅ ✅ ✅
TestAccept/bundle/templates/default-python/serverless-customcatalog/DMS= ✅ ✅ ✅
TestAccept/bundle/validate/variables/overrides_file_complex_path/DMS= ✅ ✅ ✅
TestAccept/bundle/validate/variables/overrides_file_complex_path/DMS=true ✅ ✅ ✅
TestAccept/bundle/validate/yaml_anchors/cycle_nested/DMS= ✅ ✅ ✅
TestAccept/bundle/validate/yaml_anchors/cycle_nested/DMS=true ✅ ✅ ✅
TestAccept/bundle/variables/file-defaults/DMS= ✅ ✅ ✅
TestAccept/bundle/variables/file-defaults/DMS=true ✅ ✅ ✅
TestAccept/cmd/auth/docker/host ✅ ✅ ✅

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 342aff2

Run: 42025872537

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 275 35 4:36
✅​ aws-windows-latest-4core-16gb 277 33 4:45
✅​ azure linux-2core-8gb 274 35 7:22
✅​ azure-windows-latest-4core-16gb 276 33 4:48
✅​ gcp linux-2core-8gb 275 35 4:41
✅​ gcp-windows-latest-4core-16gb 277 33 4:51
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:45 gcp-windows-latest-4core-16gb TestAccept
3:36 azure-windows-latest-4core-16gb TestAccept
3:34 aws-windows-latest-4core-16gb TestAccept

…og golden

The removed backslash Repl was also rewriting escaped \n and \" in notebook
JSON into /n and /".

Co-authored-by: Isaac <no-reply@databricks.com>

@Sankalp-Mittal Sankalp-Mittal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI review from review-factory: 2 independent reviewer models (Claude Fable 5.2, Claude Opus 5.5) with cross-verification. Only findings that reviewers agreed on are posted.

Wraps local paths in error text with filepath.ToSlash and drops backslash Repls. Confirmed: filer errors also rewrite remote paths; three tests skip Windows selection.

Findings: 2 minor, 1 nit.

  • acceptance/bundle/validate/yaml_anchors/test.toml minor: Three tests that lost an inherited Repl are not selected as changed on Windows

The description says the Windows cell runs the changed tests. That does not hold for three tests whose backslash Repl came from a deleted parent test.toml:

  • bundle/validate/targets/scalar_rewrite_diagnostic
  • bundle/validate/yaml_anchors/invalid_merge_sequence_member
  • bundle/validate/yaml_duplicate_keys/shadowed_invalid_subtree

The changed-test selector maps a changed file to a test only when one of the file's ancestor directories contains a script. The three parent directories do not, so their deleted test.toml files select nothing. The Windows PR cell runs a hash-selected subset plus the changed tests, so these three run there only by chance.

From reading the code they should pass: their messages come from bundle/config/root.go:126,132 and diag.Location.String(), both converted in this PR. That is not confirmed by a Windows run. Please run these three on Windows once, or confirm they were in this commit's subset, before merging.

Evidence: acceptance/internal/selection/selection.go:347-360 (testDirForFile returns "" unless an ancestor is a known test dir) and :567-570 (such files are skipped). acceptance/bundle/validate/{targets,yaml_anchors,yaml_duplicate_keys}/ contain only subdirectories, no script. The bot report in _review_factory/discussion.md says "Selected 20 changed tests (limit=20, 2 not selected)", i.e. 22, which is exactly the number of touched directories that do contain a script; the three tests above are not among them. acceptance/subset_test.go:14-17,35-39,81-96 describes the Windows/macOS PR subset. Affected goldens: acceptance/bundle/validate/targets/scalar_rewrite_diagnostic/output.txt:3, acceptance/bundle/validate/yaml_anchors/invalid_merge_sequence_member/output.txt:3, acceptance/bundle/validate/yaml_duplicate_keys/shadowed_invalid_subtree/output.txt:3 (all print [TEST_TMP_DIR]/databricks.yml).

Agreed by 2 reviewer model(s).

  • bundle/config/mutator/translate_paths.go:246 nit: Three messages in the same file still convert to backslashes

This PR switches the path %s is not contained in sync root path message (line 158) to forward slashes with filepath.ToSlash. Three neighbouring user-facing errors in the same file still call filepath.FromSlash(localFullPath), so they print backslashes on Windows:

  • line 246: unable to determine if %s is not a notebook: %w
  • line 264: %s is not a directory
  • line 283: unable to determine if %s is a directory: %w

localFullPath is already in slash form at that point (lines 162-163 normalize localPath with ToSlash before it is passed to the translate functions, e.g. translateNotebookPath at line 169), so dropping the FromSlash call is enough. This doesn't match the PR's goal of the same output on every OS. It is fine to leave for a follow-up if the PR is meant to cover only messages with acceptance coverage today; in that case consider adding these three to the list of cases left out on purpose.

Evidence: no acceptance golden contains these three messages (grep -rn "is not a directory\|unable to determine if" acceptance --include=output.txt returns nothing).

Agreed by 2 reviewer model(s).

Comment thread libs/filer/errors.go

func (err fileAlreadyExistsError) Error() string {
return "file already exists: " + err.path
return "file already exists: " + filepath.ToSlash(err.path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: ToSlash in filer Error() also rewrites remote paths on Windows

Error() of the seven filer error types now runs filepath.ToSlash on err.path. These types are shared with the DBFS, Files API and workspace filers, whose paths are POSIX strings built with path.Join; there a \ is an ordinary character, not a separator.

On Windows, a remote path that contains a backslash is now printed with / instead, so the message names a different path from the one sent to the API. Example: a Windows user types databricks fs ls dbfs:\Volumes\main and the API reports the path as missing. The error used to read no such directory: /\Volumes\main, which showed the mistake. It now reads no such directory: //Volumes/main, which looks like a valid path that does not exist.

Only local paths need converting. Apply filepath.ToSlash where libs/filer/local_client.go builds these errors and leave the Error() methods as they were.

Evidence: libs/filer/errors.go:15,34,45,59,73,88,119 wrap err.path unconditionally. Remote construction sites pass POSIX paths, e.g. libs/filer/dbfs_client.go:244 (absPath, err := w.root.Join(name)) and :259 (noSuchDirectoryError{absPath}), with Join implemented as path.Join(p.rootPath, name) at libs/filer/workspace_root_path.go:26. cmd/fs/helpers.go:38-49 passes everything after dbfs: to the remote filer unchanged. Local construction sites are only in libs/filer/local_client.go:61,63,90,96,121,128,143,149,172.

Agreed by 2 reviewer model(s).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants