Skip to content

Return early from script mutator if no script is defined - #4711

Merged
pietern merged 2 commits into
mainfrom
bundle-script-return-early
Mar 12, 2026
Merged

Return early from script mutator if no script is defined#4711
pietern merged 2 commits into
mainfrom
bundle-script-return-early

Conversation

@pietern

@pieternpietern commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Move the empty command check to the top of script.Apply so that NewCommandExecutor (which requires a shell to be available) is not called when no script hook is configured.
  • Simplify executeHook by passing the resolved command directly instead of re-fetching it from the bundle.

Found out about this dependency during investigation of #4710.

Test plan

  • Existing unit tests pass
  • No new behavior introduced; this is a refactor that reorders existing checks

🤖 Generated with Claude Code

Move the empty command check to the top of `Apply` so that
`NewCommandExecutor` (which requires a shell) is not called
when no script hook is configured. This avoids a hard
dependency on a shell being available during bundle
initialization.
Closes#4710
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eng-dev-ecosystem-bot

eng-dev-ecosystem-bot commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

Commit: 51264f3

Run: 22990970550

Env🟨​KNOWN🔄​flaky💚​RECOVERED🙈​SKIP✅​pass🙈​skipTime
🟨​aws linux7172687818:08
🟨​aws windows7172707796:00
🔄​aws-ucws linux2773646967:01
🔄​aws-ucws windows2773666946:28
💚​azure linux292717797:29
💚​azure windows292737773:56
🔄​azure-ucws linux2193696927:46
🔄​azure-ucws windows2193716906:23
💚​gcp linux292677826:38
💚​gcp windows292697804:46
16 interesting tests: 7 KNOWN, 7 SKIP, 2 flaky
Test Nameaws linuxaws windowsaws-ucws linuxaws-ucws windowsazure linuxazure windowsazure-ucws linuxazure-ucws windowsgcp linuxgcp windows
🟨​TestAccept🟨​K🟨​K💚​R💚​R💚​R💚​R💚​R💚​R💚​R💚​R
🙈​TestAccept/bundle/resources/permissions🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions🟨​K🟨​K💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions🟨​K🟨​K💚​R💚​R🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct🟨​K🟨​K💚​R💚​R
🟨​TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform🟨​K🟨​K💚​R💚​R
🙈​TestAccept/bundle/resources/postgres_branches/basic🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_branches/recreate🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_branches/update_protected🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_branches/without_branch_id🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/postgres_endpoints/recreate🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🙈​TestAccept/bundle/resources/synced_database_tables/basic🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S🙈​S
🔄​TestAccept/ssh/connect-serverless-gpu🙈​s🙈​s🔄​f🔄​f🙈​s🙈​s🔄​f🔄​f🙈​s🙈​s
🔄​TestAccept/ssh/connection💚​R💚​R🔄​f🔄​f💚​R💚​R🔄​f🔄​f💚​R💚​R
Top 23 slowest tests (at least 2 minutes):
durationenvtestname
3:47azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:45azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:19aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:18aws-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:13gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:10gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
3:05aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:03gcp linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
3:02gcp windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:56aws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:50gcp linuxTestAccept/ssh/connection
2:47aws-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:45aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:43aws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:22aws linuxTestAccept/ssh/connection
2:21gcp linuxTestSecretsPutSecretStringValue
2:19azure linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:15azure-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:13azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:10azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:07azure windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=direct
2:04aws-ucws windowsTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform
2:04azure-ucws linuxTestAccept/bundle/resources/apps/inline_config/DATABRICKS_BUNDLE_ENGINE=terraform

Comment threadbundle/scripts/scripts.go Outdated

func (m *script) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
command := getCommmand(b, m.scriptHook)
if command == "" {

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.

Is there a case for having a script but no command? like variable command?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The script hooks run after variable interpolation, so the command is always fully resolved by the time this code executes. If it resolves to empty then it is not really useful, of course...

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.

In that case I wonder why not hard error here.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I don't know, this is quite old code.

In fact, we might be able to yank the experimental scripts section entirely.

The fix here is localized to addressing something I spotted when working on #4710.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pietern
pietern enabled auto-merge March 12, 2026 07:26
@pietern
pietern added this pull request to the merge queueMar 12, 2026
Merged via the queue into main with commit b72efb9Mar 12, 2026
18 checks passed
@pietern
pietern deleted the bundle-script-return-early branch March 12, 2026 08:06
rauchy pushed a commit that referenced this pull request Mar 17, 2026
## Summary
- Move the empty command check to the top of `script.Apply` so that
`NewCommandExecutor` (which requires a shell to be available) is not
called when no script hook is configured.
- Simplify `executeHook` by passing the resolved command directly
instead of re-fetching it from the bundle.
Found out about this dependency during investigation of #4710.
## Test plan
- [x] Existing unit tests pass
- [x] No new behavior introduced; this is a refactor that reorders
existing checks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
denik pushed a commit that referenced this pull request May 20, 2026
## Summary
- Move the empty command check to the top of `script.Apply` so that
`NewCommandExecutor` (which requires a shell to be available) is not
called when no script hook is configured.
- Simplify `executeHook` by passing the resolved command directly
instead of re-fetching it from the bundle.
Found out about this dependency during investigation of #4710.
## Test plan
- [x] Existing unit tests pass
- [x] No new behavior introduced; this is a refactor that reorders
existing checks
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for freeto 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.

3 participants

@pietern@eng-dev-ecosystem-bot@denik