Skip to content

Add env section to bundle scripts for DABs interpolation#5299

Open
shreyas-goenka wants to merge 4 commits into
mainfrom
script-env-section
Open

Add env section to bundle scripts for DABs interpolation#5299
shreyas-goenka wants to merge 4 commits into
mainfrom
script-env-section

Conversation

@shreyas-goenka

@shreyas-goenka shreyas-goenka commented May 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #4179.

Adds an env: map to scripts.<name>. Values may reference ${bundle.*}, ${workspace.*}, and ${var.*}; they're resolved before the script runs and exported into its shell, where content uses plain $NAME:

scripts:
  show_env:
    env:
      REGION: ${var.region}
    content: echo "region=$REGION"

content is still passed to the shell as-is, so ${...} in content stays unsupported (the error now points to the env: section). Env values with any other prefix (e.g. ${resources.*}) are rejected. On a name collision with the CLI-injected auth vars, the script's env: wins.

This pull request was AI-assisted by Isaac.

@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 46a34af

Run: 28827862716

Env 💚​RECOVERED 🙈​SKIP ✅​pass 🙈​skip Time
💚​ aws linux 4 4 230 1065 9:40
💚​ aws windows 4 4 232 1063 6:03
💚​ aws-ucws linux 4 4 314 983 5:13
💚​ aws-ucws windows 4 4 316 981 6:16
💚​ azure linux 4 4 230 1064 6:02
💚​ azure windows 4 4 232 1062 6:13
💚​ azure-ucws linux 4 4 316 980 6:46
💚​ azure-ucws windows 4 4 318 978 6:06
💚​ gcp linux 4 4 229 1066 6:46
💚​ gcp windows 4 4 231 1064 5:52
8 interesting tests: 4 RECOVERED, 4 SKIP
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
💚​ TestAccept 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
🙈​ TestAccept/bundle/invariant/no_drift 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_endpoints/drift/recreated_same_name 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/bundle/resources/vector_search_indexes/recreate/embedding_dimension 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
🙈​ TestAccept/ssh/connection 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S 🙈​S
💚​ TestFetchRepositoryInfoAPI_FromRepo 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/root 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
💚​ TestFetchRepositoryInfoAPI_FromRepo/subdir 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R 💚​R
Top 15 slowest tests (at least 2 minutes):
duration env testname
7:17 aws linux TestSecretsPutSecretStringValue
5:24 aws-ucws windows TestAccept
5:11 aws windows TestAccept
5:11 azure windows TestAccept
5:10 azure-ucws windows TestAccept
5:06 gcp windows TestAccept
4:02 gcp linux TestSecretsPutSecretStringValue
2:52 aws-ucws linux TestAccept
2:50 aws linux TestAccept
2:49 azure linux TestAccept
2:48 gcp linux TestAccept
2:47 azure-ucws linux TestAccept
2:39 gcp windows TestSecretsPutSecretStringValue
2:14 azure-ucws linux TestSecretsPutSecretStringValue
2:04 azure linux TestSecretsPutSecretStringValue

@shreyas-goenka shreyas-goenka force-pushed the script-env-section branch 5 times, most recently from f373d61 to b68897d Compare June 29, 2026 16:37
scripts.<name> now accepts an env: map whose values may reference
${bundle.*}, ${workspace.*}, and ${var.*}. The script content is still
passed to the shell as-is (no DABs interpolation), removing the ambiguity
between bundle variables and shell variables that previously forced all
${...} usage to be rejected.

When an env value references an unsupported prefix (e.g. ${resources.*}),
validation reports a clear error pointing at the field. The content-side
error now suggests the new env section instead of just stating ${...} is
unsupported.

Fixes #4179

Co-authored-by: Isaac
@shreyas-goenka shreyas-goenka marked this pull request as ready for review July 6, 2026 13:30
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Approval status: pending

/acceptance/bundle/ - needs approval

11 files changed
Suggested: @denik
Also eligible: @pietern, @janniklasrose, @andrewnester, @anton-107, @lennartkats-db

/bundle/ - needs approval

4 files changed
Suggested: @denik
Also eligible: @pietern, @janniklasrose, @andrewnester, @anton-107, @lennartkats-db

/cmd/bundle/ - needs approval

Files: cmd/bundle/run.go
Suggested: @denik
Also eligible: @pietern, @janniklasrose, @andrewnester, @anton-107, @lennartkats-db

General files (require maintainer)

Files: NEXT_CHANGELOG.md
Based on git history:

  • @denik -- recent work in ./, cmd/bundle/, bundle/config/

Any maintainer (@andrewnester, @anton-107, @denik, @pietern, @simonfaltum, @renaudhartert-db, @janniklasrose) can approve all areas.
See OWNERS for ownership rules.

Resolved conflicts in NEXT_CHANGELOG.md (kept both entry sets) and
bundle/internal/schema/annotations.yml (took main's regenerated layout,
re-added the scripts env field annotation).

Co-authored-by: Isaac
Comment thread acceptance/bundle/run/scripts/env-bad-prefix/output.txt
Comment thread NEXT_CHANGELOG.md Outdated
Fix the earlier bad merge in NEXT_CHANGELOG.md: the prior merge
resurrected Bundles entries that had already been swept into the
v1.6.0 release. Reset the changelog to origin/main and re-added only
the scripts env entry.

Co-authored-by: Isaac
PLACEHOLDER
"env":
"description": |-
PLACEHOLDER

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.

please add a description here so it shows up in tooltips via the jsonschema

Comment thread cmd/bundle/run.go
Comment on lines +281 to +286
env := scriptEnv(cmd, b)
// Append after the auth/target variables so a script's env: section takes
// precedence on collision (os/exec uses the last value for a duplicate key).
for _, name := range slices.Sorted(maps.Keys(script.Env)) {
env = append(env, name+"="+script.Env[name])
}

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.

add an acceptance test for this

@@ -0,0 +1 @@
errcode trace $CLI bundle validate

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.

Suggested change
errcode trace $CLI bundle validate
musterr trace $CLI bundle validate

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature suggestion - variable interpolation in DAB script

4 participants