Skip to content

Conversation

@BohdanTkachenko
Copy link

@BohdanTkachenko BohdanTkachenko commented Dec 14, 2025

Previously, the codegen template incorrectly treated integer values of 0 as null/empty when converting XML to Terraform state. This caused PCI address fields (domain, bus, slot, function) with value 0 to be returned as null, resulting in "Provider produced inconsistent result after apply" errors.

Most PCI devices have domain=0, and many have slot=0 or function=0 (e.g., 0000:03:00.0), making PCI passthrough unusable without workarounds.

The fix removes the != 0 checks from convert.go.tmpl:

  • For pointer fields: only check != nil
  • For non-pointer fields: always set the value

This affects 8 locations in the template covering computed, optional, and flattened value attribute fields.

Fixes #1246: perpetual drift for PCI passthrough devices where any address component equals.

Previously, the codegen template incorrectly treated integer values of 0
as null/empty when converting XML to Terraform state. This caused PCI
address fields (domain, bus, slot, function) with value 0 to be returned
as null, resulting in "Provider produced inconsistent result after apply"
errors.

Most PCI devices have domain=0, and many have slot=0 or function=0
(e.g., 0000:03:00.0), making PCI passthrough unusable without workarounds.

The fix removes the `!= 0` checks from convert.go.tmpl:
- For pointer fields: only check `!= nil`
- For non-pointer fields: always set the value

This affects 8 locations in the template covering computed, optional,
and flattened value attribute fields.

Fixes perpetual drift for PCI passthrough devices where any address
component equals 0.
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.

PCI address fields with value 0 returned as null causing perpetual drift

1 participant