Skip to content

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

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: 301d3eef4f75a970f3cfb02cdb5b88b480024d2e

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