Skip to content

[factory:bug-fixer][custom-training] Prevent AIR conversion from creating a second bundle root - #7853

Merged
ben-hansen-db merged 3 commits into
mainfrom
ben-hansen_data/ben-hansen/rf-cnxt-2666-retry
Nov 20, 2026
Merged

ben-hansen-db merged 3 commits into
mainfrom
ben-hansen_data/ben-hansen/rf-cnxt-2666-retry

Conversation

@ben-hansen-db

@ben-hansen-db ben-hansen-db commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Changes

databricks air convert-to-dabs checks the output directory before writing the bundle. If databricks.yaml, bundle.yml, or bundle.yaml exists, conversion stops with or without --force and names the root to move or remove. This also applies when databricks.yml is present alongside it. A lone databricks.yml can still be overwritten with --force.

Why

Conversion writes databricks.yml, and the bundle loader rejects a directory with two roots. When both roots already existed, forcing conversion overwrote edits to databricks.yml and left the conflict in place. Reported collision

Both examples start with the same training configuration and one existing databricks.yaml.

Before

Conversion exited 0 and created a second root. The subsequent databricks bundle validate exited 1 with multiple bundle root configuration files found.

$ databricks air convert-to-dabs train.yaml --force
Wrote a Databricks Asset Bundle to .:
  databricks.yml
  …
$ ls -1 databricks.y*
databricks.yaml
databricks.yml

After

Conversion exits 1. The original file keeps its bytes and no generated_artifacts/ directory is created.

$ databricks air convert-to-dabs train.yaml --force
Error: databricks.yaml already exists in .; move or remove it before converting
$ ls -1 databricks.y*
databricks.yaml

Tests

Nine cases cover forced alias-only collisions and mixed roots with and without --force. They check the exact remedy, the bytes of existing files, and whether an artifact directory was created. All nine failed when the production change was reverted to the published head and passed 50 repetitions after restoration. CLI fixtures also verified canonical-only overwrite and conversion to a separate output directory.

./task fmt, ./task checks, ./task lint, and ./task test passed. The completion acceptance test passed on the test runner’s automatic retry. Shell completion previously reproduced exit 141 with both the published CLI and the first candidate.

This PR was written with OpenAI Codex.

@github-actions github-actions Bot added the AIR Databricks AI Runtime CLI label Nov 20, 2026
@ben-hansen-db
ben-hansen-db marked this pull request as ready for review November 20, 2026 19:05
@ben-hansen-db
ben-hansen-db requested review from a team as code owners November 20, 2026 19:05

@review-oss-bot review-oss-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review at 232b0c7. Each finding was verified against the code.

Not ready yet: 1 blocking issue(s), tagged [blocking].

This PR adds a guard in writeBundle that checks all four supported bundle configuration filenames (databricks.yml, databricks.yaml, bundle.yml, bundle.yaml) before writing, preventing a dual-root situation when running convert-to-dabs without --force. The non-force path is correctly fixed and well-tested. However, the --force path is not guarded: when a non-databricks.yml root file already exists and --force is passed, the converter still writes databricks.yml alongside it, producing the same dual-root breakage the PR aims to prevent.

Comment thread cmd/air/convert_to_dabs.go Resolved
@eng-dev-ecosystem-bot

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

Copy link
Copy Markdown
Collaborator

✅ Integration test report

Commit: 9e28cc1

Run: 44813637002

Env 💚​RECOVERED ✅​pass 🙈​skip Time
💚​ aws linux-2core-8gb 1 272 19 5:12
💚​ aws-windows-latest-4core-16gb 1 274 17 4:28
💚​ azure linux-2core-8gb 1 271 19 4:51
💚​ azure-windows-latest-4core-16gb 1 273 17 4:31
💚​ gcp linux-2core-8gb 1 272 19 5:55
💚​ gcp-windows-latest-4core-16gb 1 274 17 4:17
Test Name aws linux-2core-8gb aws-windows-latest-4core-16gb azure linux-2core-8gb azure-windows-latest-4core-16gb gcp linux-2core-8gb gcp-windows-latest-4core-16gb
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 3 slowest tests (at least 2 minutes):
duration env testname
4:29 azure-windows-latest-4core-16gb TestAccept
4:09 aws-windows-latest-4core-16gb TestAccept
3:56 gcp-windows-latest-4core-16gb TestAccept

@ben-hansen-db
ben-hansen-db added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 31402a8 Nov 20, 2026
28 checks passed
@ben-hansen-db
ben-hansen-db deleted the ben-hansen_data/ben-hansen/rf-cnxt-2666-retry branch November 20, 2026 21:38
idelafuente-oc pushed a commit to idelafuente-oc/cli that referenced this pull request Nov 22, 2026
databricks#7857)

## Changes

`databricks air convert-to-dabs` now checks the `bundle.name` of the
`databricks.yml` already in the output directory. If it belongs to a
different bundle than the workload being converted, conversion stops
with or without `--force`, and the error names both bundles and points
at `--output-dir`. The usual "pass --force to overwrite" hint is given
only when `--force` can resolve the collision. `--force` still
re-converts the same workload (and still replaces a `databricks.yml`
that declares no `bundle.name`, such as a hand-edited stub).

When a forced re-conversion of the same workload writes fewer sidecars
than the previous one (for example after removing `env_variables`,
`secrets` or `parameters`), the generated names it no longer writes
(`command.sh`, `hyperparameters.yaml`, `env_vars.json`,
`secret_env_vars.json`) are removed from `generated_artifacts/` instead
of being left for `sync.paths` to upload.

## Why

Two workloads that share a code directory are both steered to the same
parent `--output-dir`. Converting the second one with `--force` silently
replaced the first one's bundle: `bundle.name` changed with no warning,
the first workload's `env_vars.json` and `secret_env_vars.json` stayed
in `generated_artifacts/` and were synced with the replacement job, and
the shared `.databricks/bundle/dev/` state would then plan to delete the
first bundle's job. [databricks#7853](databricks#7853)
made alternate root filenames fail even with `--force`, but a lone
`databricks.yml` was still overwritten without a `bundle.name`
comparison.

Jira: CNXT-2664

Both examples start with `a/workload.yaml` (`experiment_name: exp-a`,
with `env_variables` and `secrets`) already converted into `.`, then
convert `b/workload.yaml` (`experiment_name: exp-b`, without them).

### Before

```console
$ databricks air convert-to-dabs b/workload.yaml --output-dir . --force
Wrote a Databricks Asset Bundle to .:
  databricks.yml
  generated_artifacts/training_config.yaml
  generated_artifacts/command.sh
$ grep name: databricks.yml | head -1
  name: exp-b
$ ls generated_artifacts
command.sh  env_vars.json  secret_env_vars.json  training_config.yaml
```

### After

```console
$ databricks air convert-to-dabs b/workload.yaml --output-dir . --force
Error: databricks.yml in . belongs to bundle "exp-a", not to this workload's bundle "exp-b"; pass --output-dir with another directory that contains the code directory
$ grep name: databricks.yml | head -1
  name: exp-a
```

Re-converting `a/workload.yaml` itself with `--force` after dropping its
`env_variables` and `secrets` now leaves only `command.sh` and
`training_config.yaml` in `generated_artifacts/`.

## Tests

Two new unit tests beside the existing `--force` tests: one converts a
second workload into a directory holding the first one's bundle and
checks the exact error with and without `--force`, and that
`databricks.yml` and the first workload's sidecars are untouched; the
other re-converts the same workload with `--force` after dropping its
sidecar inputs and checks the stale sidecars are gone while `command.sh`
remains.

The `acceptance/air/convert-to-dabs` test forced `databricks-ai.yaml`
over the torchrun bundle in the same directory, which is the replacement
this change refuses; it now shows that refusal and converts into
`generated-databricks-ai` instead.

`go test ./cmd/air/...` passes for the `convert-to-dabs` tests, the
acceptance test passes, `task lint-q` reports no issues, and `task
check-changelog` passes.

## Review notes

review-oss-bot suggested wiping `generated_artifacts/` with
`os.RemoveAll` under `--force` instead of removing the four known
sidecar names. Left as is for now: the explicit list only deletes files
this command wrote, while a wipe would also remove anything a user
placed in that directory. If `buildArtifacts` gains another conditional
sidecar, the list needs the new name.

review-oss-bot also suggested refusing when the existing
`databricks.yml` does not parse at all, since its bundle is then
unknown. Left as is: a file that declares no readable `bundle.name` was
already replaceable with `--force` before this change (a hand-edited
stub, for example), and a file that still parses keeps its name checked.

This pull request and its description were written by Isaac.

---------

Co-authored-by: Isaac <no-reply@databricks.com>
deco-sdk-tagging Bot added a commit that referenced this pull request Nov 24, 2026
## Release v1.28.0

### CLI

 * Retry transient errors in `fs` commands: `fs cp` to a UC Volume from another Volume or DBFS (files up to 8 MiB) on HTTP 503, DBFS uploads when the upload stream is lost, and stat, read and list on UC Volumes on HTTP 500. ([#7607](#7607), [#7763](#7763), [#7839](#7839))
 * `databricks auth profiles --skip-validate` now omits the `Valid` column instead of reporting `NO` for every profile. ([#7638](#7638))
 * Fix Ctrl-C taking about 10 seconds to stop `databricks aitools install`, `update` or `uninstall` while it runs a coding agent's CLI, and retry reading an agent's config on Windows while the agent rewrites it. ([#7832](#7832), [#7870](#7870))
 * Automatic installation of Databricks AI tools no longer asks in containers or installs for the first time without a terminal, no longer runs as root in another user's home, keeps newer skills you installed, no longer hints to install what it is about to install, and on Linux and macOS stops the calling script on Ctrl-C. ([#7828](#7828), [#7834](#7834), [#7874](#7874), [#7888](#7888), [#7890](#7890), [#7901](#7901))
 * Wait before retrying a failed automatic install of Databricks AI tools, starting at 5 minutes and doubling after each failure, so a skills source or coding agent CLI that stays broken no longer slows down each of the next commands. ([#7900](#7900))
 * `databricks aitools install` now cancels the agent picker on Esc. ([#7721](#7721))
 * `databricks aitools uninstall --skills` now fails when its value names no skill instead of removing every skill, and `aitools update` and `uninstall` no longer prompt when a coding agent runs them; with skills in both scopes they fail and ask for `--scope`. ([#7873](#7873))
 * `databricks aitools install --skills-only` and `databricks aitools update` no longer mix skill files with the Databricks plugin: install skips agents that already have the plugin, and update no longer replaces skill files from a `--skills-only` install made with this release or later while the agent's CLI was on PATH. To keep skill files from an earlier `--skills-only` install, run `databricks aitools install --skills-only` again with the agent's CLI on PATH. ([#7831](#7831), [#7903](#7903))
 * `apps init` no longer suggests installing skills to Codex and Copilot users who installed the Databricks plugin with `databricks aitools install`. ([#7830](#7830))
 * Fix `databricks auth login` failing with `data passed to Set was too big` on macOS and Windows for OAuth tokens too large for one keyring item. ([#7845](#7845))
 * Fix the token storage mode (`auth_storage`) being read from the file named by `DATABRICKS_CONFIG_FILE` instead of the config file the profile was loaded from. ([#7733](#7733))
 * `databricks auth login` no longer waits for the browser that the default opener starts to close before it continues. ([#7551](#7551))
 * Allow `databricks auth docker configure` when several profiles match one workspace; the chosen profile is recorded for the registry and shown by `databricks auth docker host`. ([#7383](#7383))
 * Show the HTTP status, error code and endpoint when an API error has no message, instead of a bare `Error: `, and the HTTP status and path for Files API errors that used to show an empty `databricks-api error:`. ([#7800](#7800), [#7839](#7839))
 * AI agents can now submit feedback without confirmation; `--yes`/`-y` is deprecated, and agents passing `--yes=false` now get an error. ([#7795](#7795))
 * Log `/.well-known/databricks-config` fetch failures with a transient HTTP status (408, 429, or 5xx other than 501) at debug level instead of as a warning, like timeouts. ([#7912](#7912))
 * Fix interactive list output sometimes dropping or reordering a page of rows. ([#7804](#7804), [#7914](#7914))
 * Allow `databricks sandbox forward` to forward remote ports below 10000. The sandbox refuses a few reserved platform ports with an error that names the port. ([#7861](#7861))
 * Breaking: `databricks sandbox ssh` now uses local SSH keys and works with sandboxes created through the SDK or API; it no longer accepts `--port` and needs Python 3 and `openssh-server` in the sandbox. Add `databricks sandbox ssh-setup` to configure native SSH and SCP. ([#7588](#7588), [#7589](#7589), [#7590](#7590))
 * `databricks ssh connect` to serverless CPU compute now defaults to environment version 5, so the first connection after upgrading starts a new server; pass `--environment-version 4` to keep the old one. ([#7847](#7847))
 * `databricks ssh connect` now downloads the SSH server binaries from PyPI when GitHub is unreachable, using `PIP_INDEX_URL` or `index-url` from the per-user pip config over HTTPS only, and checks SHA-256 digests. ([#7852](#7852))

### AI Runtime

 * Breaking: `compute.pool_id` is no longer accepted in AIR workload YAML; use `compute.accelerator_pool_id`. ([#7698](#7698))
 * `databricks air convert-to-dabs` handles an existing output directory better: it gives the right guidance when the directory already holds the workload's bundle, `--force` no longer replaces a different bundle or an alternate root file, re-converting removes stale sidecars, and git-pinned code outside the bundle gets an `--output-dir` suggestion. ([#7835](#7835), [#7853](#7853), [#7857](#7857), [#7866](#7866))
 * `air list` and `air get` now find the AI Runtime task anywhere in a multi-task job; a job with several such tasks lists one row per task (so `run_id` is no longer unique in `air list -o json`), and both report `task_key` (`air get --task-key` selects one). `air list --all-status` now orders runs by submission time instead of by their latest attempt's start. ([#7632](#7632))
 * Update fallback messages for pending AI Runtime runs when AIR does not report a status reason. ([#7899](#7899))
 * `air run -o json` now reports config-validation errors as a JSON error envelope, with `UNAUTHENTICATED`, `INVALID_ARGS` or the new `PERMISSION_DENIED` code. ([#7864](#7864))

### Bundles

 * Bundle commands no longer hang after a request timeout on a dead HTTP/2 connection. ([#7723](#7723))
 * Fix a panic when the local Terraform state is removed after it is pulled and before it is migrated to the direct engine, for example by a concurrent `bundle deploy`. ([#7778](#7778))
 * The direct deployment engine now uses a Lakebase or postgres catalog that a failed create request still created, instead of failing the deploy. ([#7801](#7801))
 * `bundle deploy` and `bundle run` for apps now succeed when the app's compute is already active or starting, and deploy the app when the deployment triggered by start failed. ([#7709](#7709), [#7780](#7780))
 * Add `thumbnail_path` to the `apps` resource, so `bundle deploy` sets, updates and deletes the thumbnail shown for the app in the Apps UI. ([#7728](#7728))
 * 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](#7851))
 * `bundle run` and `pipelines run` now retry transient errors from the pipeline events and update status reads while waiting for an update. ([#7800](#7800))

### Dependency Updates

 * Bump dependencies with known vulnerabilities. ([#7904](#7904))
 * Update the Go SDK to [v0.203.0](https://github.com/databricks/databricks-sdk-go/releases/tag/v0.203.0). ([#7869](#7869), [#7906](#7906))
 * Update `github.com/databricks/sdk-go/files` to [v0.9.0](https://github.com/databricks/sdk-go/blob/files/v0.9.0/files/CHANGELOG.md). ([#7889](#7889))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIR Databricks AI Runtime CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants