Skip to content

Conversation

@alexott
Copy link
Contributor

@alexott alexott commented Oct 22, 2025

Changes

Fixes #4672

This commit addresses the issue where Databricks API may add or remove the /Workspace prefix in paths depending on workspace configuration, causing Terraform to detect false changes and produce 'inconsistent final plan' errors.

Changes:

  • Added NormalizeWorkspacePath() function in workspace/file_resource.go to normalize path returned from API to match configured path
  • Updated workspace resources (databricks_workspace_file, databricks_notebook, databricks_directory) to use path normalization in Read operations
  • Updated SQL resources (databricks_query, databricks_alert) to use path normalization for parent_path field
  • Fixed bugs in sql/resource_query.go and sql/resource_alert.go where wrong variable was used in path normalization
  • Added comprehensive unit tests (8 test cases) for path normalization
  • Added integration test for workspace prefix normalization

The fix handles both directions:

  • Strips /Workspace when API adds it but config doesn't have it
  • Adds /Workspace when config has it but API doesn't have it

This ensures the path in state always matches what user configured, preventing Terraform from detecting drift when there is none.

Tests

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • using Go SDK
  • using TF Plugin Framework
  • has entry in NEXT_CHANGELOG.md file

Fixes #4672

This commit addresses the issue where Databricks API may add or remove the
/Workspace prefix in paths depending on workspace configuration, causing
Terraform to detect false changes and produce 'inconsistent final plan' errors.

Changes:
- Added NormalizeWorkspacePath() function in workspace/file_resource.go to
  normalize path returned from API to match configured path
- Updated workspace resources (databricks_workspace_file, databricks_notebook,
  databricks_directory) to use path normalization in Read operations
- Updated SQL resources (databricks_query, databricks_alert) to use path
  normalization for parent_path field
- Fixed bugs in sql/resource_query.go and sql/resource_alert.go where wrong
  variable was used in path normalization
- Added comprehensive unit tests (8 test cases) for path normalization
- Added integration test for workspace prefix normalization

The fix handles both directions:
- Strips /Workspace when API adds it but config doesn't have it
- Adds /Workspace when config has it but API doesn't have it

This ensures the path in state always matches what user configured, preventing
Terraform from detecting drift when there is none.
@alexott alexott requested review from a team as code owners October 22, 2025 06:20
@alexott alexott requested review from parthban-db and removed request for a team October 22, 2025 06:20
@alexott alexott temporarily deployed to test-trigger-is October 22, 2025 06:20 — with GitHub Actions Inactive
@alexott alexott temporarily deployed to test-trigger-is October 22, 2025 06:21 — with GitHub Actions Inactive
@alexott alexott requested a review from tanmay-db October 27, 2025 15:34
@github-actions
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/terraform

Inputs:

  • PR number: 5130
  • Commit SHA: b7dab68d22778d51caa9ba2b3de7622566e5c680

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.

[ISSUE] Issue with databricks_workspace_file resource

2 participants