Skip to content

Add parser to distinguish valid DAB variable interpolation from bash variables in scripts #4197

Open
AryanBagade wants to merge 4 commits intodatabricks:mainfrom
AryanBagade:feature/script-variable-interpolation-parser
Open

Add parser to distinguish valid DAB variable interpolation from bash variables in scripts #4197
AryanBagade wants to merge 4 commits intodatabricks:mainfrom
AryanBagade:feature/script-variable-interpolation-parser

Conversation

@AryanBagade
Copy link

Changes

Add a parser to properly distinguish valid DAB variable interpolation from bash environment variables in scripts.

  • Added FindAllInterpolationReferences() and HasValidDABPrefix() helper functions in libs/dyn/dynvar/ref.go
  • Updated bundle/config/validate/scripts.go to allow valid DAB references (${var.x}, ${bundle.name}, etc.) while rejecting ambiguous patterns like ${FOO}
  • Improved error messages with helpful suggestions (e.g., "use $FOO for env var or ${var.FOO} for bundle variable"

Why

Previously, all ${...} patterns were blocked in scripts with a generic error message. This made it impossible to use DAB variable interpolation in scripts, forcing users to rely on environment variables as a workaround.
With this change:

  • ${var.foo}, ${bundle.name}, ${workspace.host}, etc. are now allowed and resolved
  • $HOME and ${VAR:-default} (bash syntax) continue to work
  • ${FOO} (ambiguous) shows a helpful error with suggestions

Fixes #4179

Tests

  • Added unit tests in bundle/config/validate/scripts_test.go
  • Added unit tests in libs/dyn/dynvar/ref_test.go
  • Added acceptance test acceptance/bundle/run/scripts/valid-interpolation/
  • Updated existing acceptance test acceptance/bundle/run/scripts/no-interpolation/
  • All tests pass: go test ./libs/dyn/dynvar/... ./bundle/config/validate/...
  • Lint passes: make lint (0 issues)

…variables in scripts (databricks#4179)

Signed-off-by: Aryan Bagade <aryan@aryanbagade.com>
@AryanBagade
Copy link
Author

@shreyas-goenka could you please review this PR.

@github-actions
Copy link

This PR has not received an update in a while. If you want to keep this PR open, please leave a comment below or push a new commit and auto-close will be canceled.

@github-actions github-actions bot added the Stale label Mar 14, 2026
@github-actions
Copy link

An authorized user can trigger integration tests manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 4197
  • Commit SHA: 4ab5e20334d88f8358f23f88f268882f789038e8

Checks will be approved automatically on success.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature suggestion - variable interpolation in DAB script

2 participants