Skip to content

Fix custom fields state drift#778

Open
MrKeiKun wants to merge 1 commit intoe-breuninger:masterfrom
MrKeiKun:fix-712-custom_fields-state-drift
Open

Fix custom fields state drift#778
MrKeiKun wants to merge 1 commit intoe-breuninger:masterfrom
MrKeiKun:fix-712-custom_fields-state-drift

Conversation

@MrKeiKun
Copy link
Copy Markdown
Contributor

@MrKeiKun MrKeiKun commented Oct 3, 2025

Description

  • Running terraform plan repeatedly shows the same custom fields needing to be added
  • Permanent state drift that never resolves
  • Specifically affects object reference custom fields like cloud_account on netbox_prefix resources

Changes Made

  1. Fixed flattenCustomFields function
  2. Changed from getCustomFields() to flattenCustomFields() and ensures consistent handling across all resources with custom fields
  3. Added DiffSuppressFunc which suppresses false positives between {} (empty map) and "" (empty string) and prevents spurious drift on empty custom fields
  4. Updated client configuration which configures JSON consumer to handle numeric values properly
    and uses json.Number to prevent type conversion issues

Referenced Issue: #712

@MrKeiKun MrKeiKun force-pushed the fix-712-custom_fields-state-drift branch 2 times, most recently from 8de58de to b6314a2 Compare October 11, 2025 07:32
@MrKeiKun
Copy link
Copy Markdown
Contributor Author

MrKeiKun commented Dec 1, 2025

Want me to rebase this? @fbreckle

@MrKeiKun MrKeiKun force-pushed the fix-712-custom_fields-state-drift branch from 453d29f to b1d3ca7 Compare January 31, 2026 18:11
@MrKeiKun
Copy link
Copy Markdown
Contributor Author

adjusting my fix since it sems introduces a problem

… handling object references, and suppressing nil/empty diffs.

Signed-off-by: Lorenzo Buitizon <the.keikun@gmail.com>
@MrKeiKun MrKeiKun force-pushed the fix-712-custom_fields-state-drift branch from b1d3ca7 to 2ad4cf9 Compare January 31, 2026 18:30
@MrKeiKun
Copy link
Copy Markdown
Contributor Author

@fbreckle for your review.

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.

1 participant