Terraform Provider: api_key expires_at format inconsistency causes apply failure #138

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

Originally created by @listellm on 1/23/2026

Description

The oneuptime_api_key resource fails during creation with "Provider produced inconsistent result after apply" error due to expires_at field format inconsistency.

Problem

When creating an API key, the provider sends wrapped DateTime format but receives unwrapped format:

Terraform sends:

{
  "_type": "DateTime",
  "value": "2030-12-31T00:00:00.000Z"
}

API returns:

"2030-12-31T00:00:00.000Z"

This causes the error:

Error: Provider produced inconsistent result after apply

When applying changes to oneuptime_api_key.this, provider 
"provider[\"registry.terraform.io/oneuptime/oneuptime\"]" produced an
unexpected new value: .expires_at: was
cty.StringVal("{\"_type\":\"DateTime\",\"value\":\"2030-12-31T00:00:00.000Z\"}"),
but now cty.StringVal("2030-12-31T00:00:00.000Z").

Expected Behaviour

The provider should either:

  1. Send unwrapped format to match API response, OR
  2. Receive wrapped format from API to match what was sent

Reproduction

resource "oneuptime_api_key" "test" {
  project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  name       = "test-key"
  expires_at = jsonencode({
    _type = "DateTime"
    value = "2030-12-31T00:00:00.000Z"
  })
}

Run terraform apply - fails with inconsistent result error.

Workaround Attempted

Using lifecycle { ignore_changes = [expires_at] } doesn't help because the error occurs during initial creation, not updates.

Environment

  • Terraform: >= 1.12.0
  • Provider: oneuptime/oneuptime v9.4.7
  • Similar issue with #2247 (status_page_domain SSL fields)
*Originally created by @listellm on 1/23/2026* ## Description The `oneuptime_api_key` resource fails during creation with "Provider produced inconsistent result after apply" error due to `expires_at` field format inconsistency. ## Problem When creating an API key, the provider sends wrapped DateTime format but receives unwrapped format: **Terraform sends:** ```json { "_type": "DateTime", "value": "2030-12-31T00:00:00.000Z" } ``` **API returns:** ```json "2030-12-31T00:00:00.000Z" ``` This causes the error: ``` Error: Provider produced inconsistent result after apply When applying changes to oneuptime_api_key.this, provider "provider[\"registry.terraform.io/oneuptime/oneuptime\"]" produced an unexpected new value: .expires_at: was cty.StringVal("{\"_type\":\"DateTime\",\"value\":\"2030-12-31T00:00:00.000Z\"}"), but now cty.StringVal("2030-12-31T00:00:00.000Z"). ``` ## Expected Behaviour The provider should either: 1. Send unwrapped format to match API response, OR 2. Receive wrapped format from API to match what was sent ## Reproduction ```hcl resource "oneuptime_api_key" "test" { project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" name = "test-key" expires_at = jsonencode({ _type = "DateTime" value = "2030-12-31T00:00:00.000Z" }) } ``` Run `terraform apply` - fails with inconsistent result error. ## Workaround Attempted Using `lifecycle { ignore_changes = [expires_at] }` doesn't help because the error occurs during initial creation, not updates. ## Environment - Terraform: >= 1.12.0 - Provider: oneuptime/oneuptime v9.4.7 ## Related Issues - Similar issue with #2247 (status_page_domain SSL fields)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#138