Skip to content

fix: resolve perpetual Terraform plan diffs for workspace_profile and data_sources#176

Merged
d-bytebase merged 2 commits intomainfrom
fix/perpetual-diff
Mar 25, 2026
Merged

fix: resolve perpetual Terraform plan diffs for workspace_profile and data_sources#176
d-bytebase merged 2 commits intomainfrom
fix/perpetual-diff

Conversation

@vsai12
Copy link
Copy Markdown
Contributor

@vsai12 vsai12 commented Mar 25, 2026

Summary

  • Fix bytebase_setting.workspace_profile perpetual -> null diff by marking server-managed optional fields as Computed
  • Fix bytebase_instance.data_sources perpetual remove/add diff by guarding Redis-specific fields behind engine type check in flatten

Problem

workspace_profile: Fields like sql_result_size, query_timeout_in_seconds, and password_restriction are server-managed with defaults. The read function writes server values to state, but the update only patches fields present in HCL (via field masks). Without Computed, Terraform plans to null them when absent from config, but apply never sends the change — causing a perpetual diff.

data_sources: The API returns redisType: STANDALONE for all data sources regardless of engine type. The flatten function wrote this to state, changing the TypeSet hash vs the config-side hash (which lacks redis_type for non-Redis instances), causing perpetual remove/add churn.

Test plan

  • Reproduced both issues locally with a minimal Terraform config
  • Verified both fixes produce clean terraform plan after terraform apply
  • Verified apply → plan → plan cycle shows no drift
  • go build compiles cleanly

🤖 Generated with Claude Code

vsai12 and others added 2 commits March 24, 2026 17:35
…petual diff

Fields like sql_result_size, query_timeout_in_seconds, password_restriction,
external_url, and token duration fields are server-managed with defaults.
Without Computed, Terraform plans to null them when absent from HCL, but the
update never sends the change (field mask excludes them), causing a
perpetual diff.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The API returns redisType: STANDALONE for all data sources regardless of
engine. The flatten function wrote this to state, changing the TypeSet hash
vs the config-side hash (which lacks redis_type for non-Redis instances).
Guard redis-specific fields behind an engine check so they only appear
in state for Redis instances.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@d-bytebase d-bytebase requested a review from ecmadao March 25, 2026 01:04
@d-bytebase d-bytebase merged commit 1191aa1 into main Mar 25, 2026
3 checks passed
@d-bytebase d-bytebase deleted the fix/perpetual-diff branch March 25, 2026 01:49
@vsai12 vsai12 mentioned this pull request Mar 25, 2026
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.

3 participants