Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid region sent when state mismatch #37

Closed
rahulpsd18 opened this issue Nov 17, 2022 · 2 comments
Closed

Invalid region sent when state mismatch #37

rahulpsd18 opened this issue Nov 17, 2022 · 2 comments

Comments

@rahulpsd18
Copy link

rahulpsd18 commented Nov 17, 2022

After creating a monitor resource, if the monitor is updated from the betteruptime dashboard, the next deployments start failing with error:

Error: PATCH https://betteruptime.com/api/v2/monitors/[MONITOR_ID] returned 422: {"errors":{"regions":["are not included in the list: us, eu, as, au"]}}

This can be replicated following the steps:

  1. Create a monitor

    resource "betteruptime_monitor" "this" {
      url          = "https://example.com"
      monitor_type = "status"
    }

    This creates a monitor with regions: null. Which is perfectly fine.
    Deploying this multiple times works fine.

  2. Now open your betteruptime dashboard and update "On call escalation" (region is not updated):

  3. Now deployment starts failing with aforementioned error.

  4. The tf plan shows the following change:

    ~ resource "betteruptime_monitor" "this" {
        ~ regions = [
              - "us",
              - "eu",
              - "as",
              - "au",
          ]
          ... // truncated
      }
    
  5. I assume regions: [] is being sent in the PATCH HTTP call, which fails with 422 from betteruptime (as verified with Postman).

  6. It should be regions: null in the Patch HTTP call. Even if we want this to fail, a user friendly message would be of greater help than a 422 error.


The error here is HTTP Patch call being sent with regions: [], which is not accepted by betteruptime and fails with 422.
It should either be a valid region array with atleast 1 region OR null.

@rahulpsd18 rahulpsd18 changed the title Incorrect region sent Invalid region sent when state mismatch Nov 17, 2022
@adikus
Copy link
Contributor

adikus commented Nov 17, 2022

Thanks for the issue and thorough description @rahulpsd18!
We'll have a look into fixing this.

@gyfis
Copy link
Contributor

gyfis commented Dec 6, 2022

@rahulpsd18 Thanks again for opening the issue. I looked into it, and based on the open issues in Terraform, I wasn't able to figure out a good enough fix for this one.

As such, I'm sorry to say I run out of ideas here. If you got any tips, happy to reopen the issue & address in a proper way; until then, I'd recommend always setting the regions in the resource specifications explicitly, which will solve the problem for you as well.

@gyfis gyfis closed this as completed Dec 6, 2022
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

No branches or pull requests

3 participants