BetterStackHQ / terraform-provider-better-uptime

Apache License 2.0
45 stars 12 forks source link

PATCH status page returned 422: Sorry, these attributes have unsupported values" #76

Closed landsman closed 1 month ago

landsman commented 3 months ago

I successfuly created resources in Uptime but I am not able to do any updates. Please tell me what am I missing here.

Required fields are filled out. It would help me to actually see what "unsupported values" and attributes are sent in the PATCH request to let me debug it.

Related: #75

Error

│ Error: PATCH https://betteruptime.com/api/v2/status-pages/184479 returned 422: {"errors":"Sorry, these attributes have unsupported values","allowed_values":{"layout":["vertical","horizontal"]}}
│
│   with module.uptime.betteruptime_status_page.this,
│   on ../modules/better-stack-uptime/main.tf line 7, in resource "betteruptime_status_page" "this":
│    7: resource "betteruptime_status_page" "this" {
│

Code

provider "betteruptime" {
  api_token = var.api_token
}

### status page ###

resource "betteruptime_status_page" "this" {
  company_name = "Company"
  company_url  = var.domain
  contact_url  = "mailto:heloo@company.com"
  timezone     = "Europe/Prague"
  subdomain    = "company-dev"
}

resource "betteruptime_status_page_section" "monitors" {
  status_page_id = betteruptime_status_page.this.id
  name           = "App"
  position       = 0
}

### monitors ###

resource "betteruptime_monitor" "app_onboarding" {
  url          = "${var.domain}/start"
  monitor_type = "status"
}

resource "betteruptime_monitor" "app_profile" {
  url          = "${var.domain}/landsman"
  monitor_type = "status"
}

resource "betteruptime_monitor" "app_profile_wall" {
  url          = "${var.domain}/landsman/wall"
  monitor_type = "status"
}

resource "betteruptime_monitor" "app_profile_stats" {
  url          = "${var.domain}/landsman/stats"
  monitor_type = "status"
}

resource "betteruptime_monitor" "app_profile_bio" {
  url          = "${var.domain}/landsman/bio"
  monitor_type = "status"
}

### link monitors to status page ###

resource "betteruptime_status_page_resource" "app_onboarding" {
  status_page_id = betteruptime_status_page.this.id
  resource_id    = betteruptime_monitor.app_onboarding.id
  resource_type  = "Monitor"
  public_name    = "onboarding"
}

resource "betteruptime_status_page_resource" "app_profile" {
  status_page_id = betteruptime_status_page.this.id
  resource_id    = betteruptime_monitor.app_profile.id
  resource_type  = "Monitor"
  public_name    = "profile index"
}

resource "betteruptime_status_page_resource" "app_profile_wall" {
  status_page_id = betteruptime_status_page.this.id
  resource_id    = betteruptime_monitor.app_profile_wall.id
  resource_type  = "Monitor"
  public_name    = "profile wall"
}

resource "betteruptime_status_page_resource" "app_profile_stats" {
  status_page_id = betteruptime_status_page.this.id
  resource_id    = betteruptime_monitor.app_profile_stats.id
  resource_type  = "Monitor"
  public_name    = "profile stats"
}

resource "betteruptime_status_page_resource" "app_profile_bio" {
  status_page_id = betteruptime_status_page.this.id
  resource_id    = betteruptime_monitor.app_profile_bio.id
  resource_type  = "Monitor"
  public_name    = "profile bio"
}
MartinBjerknes commented 3 months ago

If you set a value for betteruptime_status_page.layout then the error will go away. If you look at your tf plan output you'll probably see that it plans to change betteruptime_status_page.layout from vertical -> null.

Same goes for some other properties:

landsman commented 3 months ago

@MartinBjerknes But these are not flag as required fields in the doc.

MartinBjerknes commented 3 months ago

@landsman Yeah, but it works as a work around until BetterStack gets around to addressing the issue.

PetrHeinz commented 1 month ago

Hello @landsman and @MartinBjerknes, thanks for reporting it and sharing the workaround 🙌

Specifying the field as Optional and Computed will make sure the API-returned values are always respected. I've proposed a fix in https://github.com/BetterStackHQ/terraform-provider-better-uptime/pull/96 and the issue should be addressed in v0.10.0.

The shared configuration should produce no more errors after upgrading, and you can remove those properties. Apologies for the inconvenience 🙏

PetrHeinz commented 1 month ago

Just released v0.10.0 which fixes the issue with optional fields being mandatory in some cases 🙌

landsman commented 1 month ago

thanks!