You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix IPv6 subnet normalization drift on firewall rules. The Vultr API normalizes IPv6 addresses on return by stripping leading zeros per RFC 5952 (e.g., 05ff becomes 5ff). This causes Terraform to detect a perpetual diff and attempt to recreate the rule on every plan.
Adds a DiffSuppressFunc that compares parsed IP bytes instead of strings, and a StateFunc that canonicalizes the subnet on write so state always matches the API response. Handles both v4 and v6 transparently.
The type assertion val.(string) will panic if val is not a string (e.g., if Terraform passes nil or a different type). Use a type assertion with comma-ok idiom to safely handle unexpected types.
func canonicalizeIP(val interface{}) string {
- raw := val.(string)+ raw, ok := val.(string)+ if !ok {+ return ""+ }
ip := net.ParseIP(raw)
if ip == nil {
return raw
}
return ip.String()
}
Suggestion importance[1-10]: 5
__
Why: The suggestion correctly identifies a potential panic scenario from unsafe type assertion. While this is a defensive improvement, Terraform's StateFunc typically receives the correct type based on the schema definition, so the risk is low. The fix is valid and improves robustness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…FirewallRule (#714)
Description
Fix IPv6 subnet normalization drift on firewall rules. The Vultr API normalizes IPv6 addresses on return by stripping leading zeros per RFC 5952 (e.g.,
05ffbecomes5ff). This causes Terraform to detect a perpetual diff and attempt to recreate the rule on every plan.Adds a
DiffSuppressFuncthat compares parsed IP bytes instead of strings, and aStateFuncthat canonicalizes the subnet on write so state always matches the API response. Handles both v4 and v6 transparently.Related Issues
Fixes #714
Checklist: