Summary
fix_block_reorgs = 0 and keep_distance_from_tip = 0 are valid Terraform config values, but readStreamFromAPI() converts API responses of 0 into types.Int64Null() when refreshing state. That can produce a permanent config 0 vs state null diff for these optional, non-computed fields.
Where
internal/provider/stream_resource.go currently special-cases zero values in readStreamFromAPI():
if fixBlockReorgs, ok := result["fix_block_reorgs"].(float64); ok {
if fixBlockReorgs == 0 {
data.FixBlockReorgs = types.Int64Null()
} else {
data.FixBlockReorgs = types.Int64Value(int64(fixBlockReorgs))
}
}
The same pattern is used for keep_distance_from_tip.
Why this matters
Both attributes are schema.Int64Attribute{Optional: true} and their validators allow 0. Since they are not Computed, Terraform expects provider state to preserve a configured zero value after refresh. Collapsing API 0 to null makes an explicit user config indistinguishable from an omitted field and can leave a never-resolving plan diff.
Expected behavior
If the API response includes either field, the provider should preserve the numeric value exactly, including 0. If the API omits the field entirely, leaving it null is still fine.
Proposed fix
Remove the 0 -> types.Int64Null() special case and set:
data.FixBlockReorgs = types.Int64Value(int64(fixBlockReorgs))
data.KeepDistanceFromTip = types.Int64Value(int64(keepDistanceFromTip))
Summary
fix_block_reorgs = 0andkeep_distance_from_tip = 0are valid Terraform config values, butreadStreamFromAPI()converts API responses of0intotypes.Int64Null()when refreshing state. That can produce a permanent config0vs statenulldiff for these optional, non-computed fields.Where
internal/provider/stream_resource.gocurrently special-cases zero values inreadStreamFromAPI():The same pattern is used for
keep_distance_from_tip.Why this matters
Both attributes are
schema.Int64Attribute{Optional: true}and their validators allow0. Since they are notComputed, Terraform expects provider state to preserve a configured zero value after refresh. Collapsing API0to null makes an explicit user config indistinguishable from an omitted field and can leave a never-resolving plan diff.Expected behavior
If the API response includes either field, the provider should preserve the numeric value exactly, including
0. If the API omits the field entirely, leaving it null is still fine.Proposed fix
Remove the
0 -> types.Int64Null()special case and set: