Terraform Provider v9.4.2: API Key creation fails with 500 error - expires_at schema/binary mismatch #144

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

Originally created by @listellm on 1/21/2026

Problem

The oneuptime_api_key resource in Terraform Provider v9.4.2 fails to create API keys with a 500 Internal Server Error.

Environment

  • Provider version: 9.4.2
  • Terraform version: 1.14.3
  • OneUptime URL: oneuptime.com

Reproduction

resource "oneuptime_api_key" "example" {
  project_id  = "project-uuid"
  name        = "example-api-key"
  description = "Example API key"
  expires_at  = jsonencode({
    _type = "Date"
    value = "2027-12-31T23:59:59.000Z"
  })
}

Error

Error: Parse Error

  with module.api_key["project.api-key-name"].oneuptime_api_key.this,
  on modules/api_key/main.tf line 1, in resource "oneuptime_api_key" "this":
   1: resource "oneuptime_api_key" "this" {

Unable to parse api_key response, got error: API request failed with status
500: {"error":"Server Error"}

Investigation

Published Terraform Schema

The registry shows expires_at as type: "string":

"expires_at": {
  "type": "string",
  "description": "A date time object.",
  "required": true
}

Provider Source Code (v9.4.2 tag)

internal/provider/resource_api_key.go:74

"expires_at": schema.MapAttribute{
    MarkdownDescription: "A date time object.",
    Required: true,
    ElementType: types.StringType,
},

Database Model

Common/Models/DatabaseModels/ApiKey.ts:345-356

@TableColumn({
  title: "Expires At",
  type: TableColumnType.Date,
  required: true,
  description: "Date and Time when this API Key expires.",
})
@Column({
  type: ColumnType.Date,
  nullable: false,
})
public expiresAt?: Date = undefined;

Root Cause

There's a three-way mismatch:

  1. Database model: Expects a Date type
  2. Provider source code: Defines MapAttribute and sends via convertTerraformMapToInterface()
  3. Published schema: Shows as string type

When using jsonencode() to satisfy the published schema validation, the request passes Terraform validation but the OneUptime API returns 500 because it receives an incorrectly formatted value.

Expected Behavior

The provider should either:

  1. Accept a map value directly ({_type = "Date", value = "..."}) and handle the conversion internally, OR
  2. Accept an ISO 8601 string ("2027-12-31T23:59:59.000Z") and convert to the required format

Workaround

None currently available - API key creation via Terraform is blocked.

This same issue affects oneuptime_api_key_permission.permission which has the identical MapAttribute/string schema mismatch.

*Originally created by @listellm on 1/21/2026* ## Problem The `oneuptime_api_key` resource in Terraform Provider v9.4.2 fails to create API keys with a 500 Internal Server Error. ## Environment - Provider version: 9.4.2 - Terraform version: 1.14.3 - OneUptime URL: oneuptime.com ## Reproduction ```hcl resource "oneuptime_api_key" "example" { project_id = "project-uuid" name = "example-api-key" description = "Example API key" expires_at = jsonencode({ _type = "Date" value = "2027-12-31T23:59:59.000Z" }) } ``` ## Error ``` Error: Parse Error with module.api_key["project.api-key-name"].oneuptime_api_key.this, on modules/api_key/main.tf line 1, in resource "oneuptime_api_key" "this": 1: resource "oneuptime_api_key" "this" { Unable to parse api_key response, got error: API request failed with status 500: {"error":"Server Error"} ``` ## Investigation ### Published Terraform Schema The registry shows `expires_at` as `type: "string"`: ```json "expires_at": { "type": "string", "description": "A date time object.", "required": true } ``` ### Provider Source Code (v9.4.2 tag) `internal/provider/resource_api_key.go:74` ```go "expires_at": schema.MapAttribute{ MarkdownDescription: "A date time object.", Required: true, ElementType: types.StringType, }, ``` ### Database Model `Common/Models/DatabaseModels/ApiKey.ts:345-356` ```typescript @TableColumn({ title: "Expires At", type: TableColumnType.Date, required: true, description: "Date and Time when this API Key expires.", }) @Column({ type: ColumnType.Date, nullable: false, }) public expiresAt?: Date = undefined; ``` ## Root Cause There's a three-way mismatch: 1. **Database model**: Expects a Date type 2. **Provider source code**: Defines MapAttribute and sends via `convertTerraformMapToInterface()` 3. **Published schema**: Shows as string type When using `jsonencode()` to satisfy the published schema validation, the request passes Terraform validation but the OneUptime API returns 500 because it receives an incorrectly formatted value. ## Expected Behavior The provider should either: 1. Accept a map value directly (`{_type = "Date", value = "..."}`) and handle the conversion internally, OR 2. Accept an ISO 8601 string (`"2027-12-31T23:59:59.000Z"`) and convert to the required format ## Workaround None currently available - API key creation via Terraform is blocked. ## Related Issue This same issue affects `oneuptime_api_key_permission.permission` which has the identical MapAttribute/string schema mismatch.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#144