OpsLevel / terraform-provider-opslevel

Terraform provider for OpsLevel.com
https://registry.terraform.io/providers/OpsLevel/opslevel/latest/docs
MIT License
7 stars 5 forks source link

[bug] 1.1.0 unable to set owner_ids to id reference nor int #381

Open bassco opened 2 weeks ago

bassco commented 2 weeks ago

When changing/creating a filter predicate to owner_ids, validation fails.

   predicate {
-    key            = "aliases"
+    key            = "owner_ids"
     type           = "equals"
-    value          = "europe_-_motors"
+    value          = "INT" # "GUID" # an_alias # Causes a Validation bug - state manipulated
     case_sensitive = true
   }

The opslevel cli shows that the value is an integer (XXXX - redacted) that relates to the url pattern https://app.opslevel.com/teams/XXXX

The filter shows the INT value, XXXX

opslevel get filter FILTER_GUID
...
    {
      "key": "owner_ids",
      "type": "equals",
      "value": "XXXX",
      "caseSensitive": true
    }
  ]
}

When setting the value in the resource to XXXX we get the following validation error.

opslevel_filter.adr-m-0021: Modifying... [id=REDACTED_FILTER_GUID]

Error: opslevel client error

  with opslevel_filter.adr-m-0021,
  on filters.tf line 115, in resource "opslevel_filter" "adr-m-0021":
 115: resource "opslevel_filter" "adr-m-0021" {

Unable to update filter, got error: OpsLevel API Errors:
    - 'value' Invalid global id 'XXXX'

When using the FILTER_GUID identifier for the value, the following error occurs.

opslevel_filter.adr-m-0021: Modifying... [id=FILTER_GUID]

Error: Internal Error

  with opslevel_filter.adr-m-0021,
  on filters.tf line 115, in resource "opslevel_filter" "adr-m-0021":
 115: resource "opslevel_filter" "adr-m-0021" {

Could not find matching filter predicate

In order to get around this, the statefile is downloaded, the predicate edited to the XXXX value, serial number bumped and the state pushed.

This unblocks our CI pipelines.

rocktavious commented 2 weeks ago

Hey @bassco - After diving into to triage this we've found a bug in our GraphQL api where this is not actually working correctly. I have attached this issue to our internal issue for the SAAS app and i'll let you know when the GraphQL API is fixed.

The long story short is that the API should not be responding with or expect an INT as the value when the key is owner_id it should always be using the GUID.

bassco commented 2 weeks ago

Ah, brilliant. Thanks for the feedback. We hit this bug in the UI too. The Owner ( Sub Teams ) must be the last filter in the list or else the Edit fails.

Good to hear it was reproducible. They are easier to fix.

Cheers.