Skip to content
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions template/databricks.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,23 @@ resources:
app:
name: "{{.projectName}}"
description: "{{.appDescription}}"
{{- if .git.url}}

@pkosiec pkosiec Sep 2, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not safe against a CLI that does not set the git map.

The PR says older CLIs render .git.url empty and fall to the else branch. It is the opposite: with no git key, {{if .git.url}} fails hard ("nil pointer evaluating interface {}.url"). Under missingkey=zero the first lookup (.git) returns a nil interface, then the chained .url panics.

In practice the default path is safe, because cli-compat.json pins each CLI version to a template tag. But --version latest, or an explicit --version <new>, on any pre-#6406 CLI clones this template and breaks.

Have the CLI set git only when detection is active (nil otherwise), and use a single with/else here. That drops the chained field access and reads cleaner:

    {{- with .git}}
          git_repository:
            url: {{.url}}
            provider: {{.provider}}
          git_source:
            branch: {{.branch}}
            source_code_path: {{.sourceCodePath}}
    {{- else}}
          source_code_path: ./
    {{- end}}

with tests the value itself, so a missing or nil git safely takes the else. This needs the CLI to pass git only when active, since a non-empty map is always truthy. (Note: text/template and does not short circuit, so {{if and .git .git.url}} would still error.)

# Git-backed deployment: the app is deployed from the Git repository below
# (auto-detected from this directory's Git remote) instead of uploading
# local files. Commit and push the branch before deploying so the ref
# exists on the remote.
git_repository:
url: {{.git.url}}
provider: {{.git.provider}}
git_source:
branch: {{.git.branch}}
source_code_path: {{.git.sourceCodePath}}
{{- else}}
# Local source: files in this directory are uploaded on deploy. To deploy
# from Git instead, run `databricks apps init` inside a Git repository that
# has a remote — the git_repository/git_source block is filled in for you.
source_code_path: ./
{{- end}}

# Start the app automatically on deploy.
lifecycle:
Expand Down
Loading