Regression: Terraform provider 'inconsistent result' error after commit 5c84699bae #156

Closed
opened 2026-04-05 16:18:58 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @listellm on 1/17/2026

Summary

Commit 5c84699bae ("fix: Enhance handling of complex object responses in ResourceGenerator") introduced a regression that breaks Terraform's round-trip consistency requirement. All Terraform operations now fail with "Provider produced inconsistent result after apply" for any resource with complex object fields.

Environment

  • Terraform Version: 1.14.3
  • Provider Version: Built locally from main branch or 9.3.22 tag
  • OS: Linux

Error Message

Error: Provider produced inconsistent result after apply

.color: was cty.StringVal("{\"_type\":\"Color\",\"value\":\"#6f42c1\"}"),
but now cty.StringVal("#6f42c1").

This is a bug in the provider, which should be reported in the provider's own issue tracker.

Root Cause

The commit incorrectly unwraps _type/value wrapper objects when reading API responses:

Before (working):

} else if (isComplexObject) {
  return `if val, ok := ${responseValue}.(map[string]interface{}); ok {
    if jsonBytes, err := json.Marshal(val); err == nil {
        ${fieldName} = types.StringValue(string(jsonBytes))
    } else {
        ${fieldName} = types.StringNull()
    }
} ...`;
}

After (broken):

} else if (isComplexObject) {
  return `if val, ok := ${responseValue}.(map[string]interface{}); ok {
    if _, hasType := val["_type"]; hasType {
        if strVal, ok := val["value"].(string); ok && strVal != "" {
            ${fieldName} = types.StringValue(strVal)  // ❌ LOSES THE WRAPPER!
        }
    }
    // ...
} ...`;
}

Terraform requires the state value to exactly match the plan value. Unwrapping the _type/value structure breaks this contract.

Affected Resources

Any resource with complex object fields:

  • oneuptime_label (color field)
  • oneuptime_monitor (monitor_steps field)
  • oneuptime_status_page (default_bar_color field)
  • oneuptime_probe (name, description fields)

Reproduction Steps

  1. Clone the repository
  2. Checkout main branch or 9.3.22 tag
  3. Run npm run generate-terraform-provider
  4. Configure ~/.terraformrc with dev_overrides pointing to local provider
  5. Create a Terraform config with oneuptime_label resource
  6. Run terraform apply
  7. Observe "inconsistent result" error

Additional Context

Tag Issue

The 9.3.22 tag appears to have been moved after the registry provider was published:

  • Published registry v9.3.22: Works (built from 7d5f813bac)
  • Current 9.3.22 tag: Points to HEAD which includes the buggy commit
7d5f813bac  chore: Bump version to 9.3.22     ← Registry provider built here
   ↓ (20 commits)
5c84699bae  fix: Enhance handling...          ← BUG INTRODUCED
   ↓
3c2811000e  refactor: Update comments...      ← 9.3.22 tag NOW points here

Suggested Fix

Revert commit 5c84699bae or restore the original JSON marshal logic that preserves the full object structure.

git revert 5c84699bae

Evidence

Test Result
Published provider v9.3.22 (registry) Works
Local build from 7d5f813bac Works
Local build from current main Fails
Local build from 9.3.22 tag Fails
*Originally created by @listellm on 1/17/2026* ## Summary Commit `5c84699bae` ("fix: Enhance handling of complex object responses in ResourceGenerator") introduced a regression that breaks Terraform's round-trip consistency requirement. All Terraform operations now fail with "Provider produced inconsistent result after apply" for any resource with complex object fields. ## Environment - **Terraform Version:** 1.14.3 - **Provider Version:** Built locally from `main` branch or `9.3.22` tag - **OS:** Linux ## Error Message ``` Error: Provider produced inconsistent result after apply .color: was cty.StringVal("{\"_type\":\"Color\",\"value\":\"#6f42c1\"}"), but now cty.StringVal("#6f42c1"). This is a bug in the provider, which should be reported in the provider's own issue tracker. ``` ## Root Cause The commit incorrectly unwraps `_type`/`value` wrapper objects when reading API responses: **Before (working):** ```typescript } else if (isComplexObject) { return `if val, ok := ${responseValue}.(map[string]interface{}); ok { if jsonBytes, err := json.Marshal(val); err == nil { ${fieldName} = types.StringValue(string(jsonBytes)) } else { ${fieldName} = types.StringNull() } } ...`; } ``` **After (broken):** ```typescript } else if (isComplexObject) { return `if val, ok := ${responseValue}.(map[string]interface{}); ok { if _, hasType := val["_type"]; hasType { if strVal, ok := val["value"].(string); ok && strVal != "" { ${fieldName} = types.StringValue(strVal) // ❌ LOSES THE WRAPPER! } } // ... } ...`; } ``` Terraform requires the state value to exactly match the plan value. Unwrapping the `_type`/`value` structure breaks this contract. ## Affected Resources Any resource with complex object fields: - `oneuptime_label` (color field) - `oneuptime_monitor` (monitor_steps field) - `oneuptime_status_page` (default_bar_color field) - `oneuptime_probe` (name, description fields) ## Reproduction Steps 1. Clone the repository 2. Checkout `main` branch or `9.3.22` tag 3. Run `npm run generate-terraform-provider` 4. Configure `~/.terraformrc` with dev_overrides pointing to local provider 5. Create a Terraform config with `oneuptime_label` resource 6. Run `terraform apply` 7. Observe "inconsistent result" error ## Additional Context ### Tag Issue The `9.3.22` tag appears to have been moved after the registry provider was published: - **Published registry v9.3.22:** Works (built from `7d5f813bac`) - **Current `9.3.22` tag:** Points to HEAD which includes the buggy commit ``` 7d5f813bac chore: Bump version to 9.3.22 ← Registry provider built here ↓ (20 commits) 5c84699bae fix: Enhance handling... ← BUG INTRODUCED ↓ 3c2811000e refactor: Update comments... ← 9.3.22 tag NOW points here ``` ## Suggested Fix Revert commit `5c84699bae` or restore the original JSON marshal logic that preserves the full object structure. ```bash git revert 5c84699bae ``` ## Evidence | Test | Result | |------|--------| | Published provider v9.3.22 (registry) | ✅ Works | | Local build from `7d5f813bac` | ✅ Works | | Local build from current `main` | ❌ Fails | | Local build from `9.3.22` tag | ❌ Fails |
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#156