Skip to content

Fix yaml config-remote-sync snapshot creation when bundle is deployed without any resources#4889

Open
ilyakuz-db wants to merge 4 commits intomainfrom
fix-yaml-sync-empty-deploy
Open

Fix yaml config-remote-sync snapshot creation when bundle is deployed without any resources#4889
ilyakuz-db wants to merge 4 commits intomainfrom
fix-yaml-sync-empty-deploy

Conversation

@ilyakuz-db
Copy link
Copy Markdown
Contributor

@ilyakuz-db ilyakuz-db commented Apr 2, 2026

Changes

UploadStateForYamlSync now handles the case where the terraform state file doesn't exist. When ParseResourcesState returns nil (no state), the mutator skips snapshot creation and returns successfully. Errors in snapshot creation/upload are now warnings instead of fatal errors.

Why

Bug:

First deploy of an empty bundle with yaml sync enabled and terraform engine failed with open .../terraform.tfstate: no such file or directory. Terraform skips apply when there are no resources, so the state file is never created. The mutator tried to read it unconditionally.

Tests

Added acceptance/bundle/config-remote-sync/empty_deploy — deploys an empty bundle with yaml sync + terraform engine.

@ilyakuz-db ilyakuz-db changed the title Fix yaml sync empty deploy Fix yaml config-remote-sync snapshot creation when bundle is deployed without any resources Apr 2, 2026
@ilyakuz-db ilyakuz-db marked this pull request as ready for review April 2, 2026 14:17
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Suggested reviewers

Based on git history of the changed files, these people are best suited to review:

  • @denik -- recent work in bundle/statemgmt/

Confidence: low

Eligible reviewers

Based on CODEOWNERS, these people or teams could also review:

@andrewnester, @anton-107, @pietern, @shreyas-goenka, @simonfaltum

Suggestions based on git history of 5 changed files (1 scored). See CODEOWNERS for path-specific ownership rules.

}

func (m *uploadStateForYamlSync) convertState(ctx context.Context, b *bundle.Bundle, snapshotPath string) (diags diag.Diagnostics) {
func (m *uploadStateForYamlSync) convertState(ctx context.Context, b *bundle.Bundle, snapshotPath string) (bool, diag.Diagnostics) {
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.

unrelated question, since it was added previously, but do you need to collect diagnostics? Why not just logs errors and warnings directly? (or logdiag.LogError/logdiag.LogError if you need diagnostics formatting).

Ignore = [".databricks", "databricks.yml"]

[Env]
DATABRICKS_BUNDLE_ENABLE_EXPERIMENTAL_YAML_SYNC = "true"
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.

I think we should have a test with empty bundle already somewhere (if not, we should have it). We can then use EnvMatrix to run it both with DATABRICKS_BUNDLE_ENABLE_EXPERIMENTAL_YAML_SYNC and without.

Perhaps there are more tests where we need to test this variant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added matrix to the acceptance/bundle/deploy/empty-bundle/test.toml

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.

2 participants