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

Updating data catalog tag template fails (google_data_catalog_tag_template) #8898

Closed
geirsagberg opened this issue Apr 13, 2021 · 12 comments · Fixed by GoogleCloudPlatform/magic-modules#4698, #8922 or hashicorp/terraform-provider-google-beta#3164
Assignees
Labels

Comments

@geirsagberg
Copy link
Contributor

geirsagberg commented Apr 13, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.14.10

  • provider registry.terraform.io/hashicorp/google v3.64.0
  • provider registry.terraform.io/hashicorp/google-beta v3.64.0

Affected Resource(s)

  • google_data_catalog_tag_template

Terraform Configuration Files

resource "google_data_catalog_tag_template" "kontaktopplysninger" {
  tag_template_id = "kontaktopplysninger"
  region          = "europe-west3"
  display_name    = "Kontaktopplysninger"

  fields {
    # 
    field_id     = "kontakttype"
    display_name = "Kontakttype"
    is_required  = true
    type {
      enum_type {
        allowed_values {
          display_name = "Individ"
        }
        allowed_values {
          display_name = "Gruppe"
        }
      }
    }
  }

  fields {
    field_id     = "epost"
    display_name = "E-post"
    is_required  = true
    type {
      primitive_type = "STRING"
    }
  }

  fields {
    field_id     = "telefonnummer"
    display_name = "Telefonnummer"
    is_required  = false # changed from true
    type {
      primitive_type = "STRING"
    }
  }
}

Debug Output

Can't show entire output, but here is the relevant part (notice the missing query string value for force=:

---[ REQUEST ]---------------------------------------
DELETE /v1/projects/saga-datacatalog-stm-jsey/locations/europe-west3/tagTemplates/kontaktopplysninger?alt=json&force= HTTP/1.1
Host: datacatalog.googleapis.com
User-Agent: Terraform/0.14.10 (+https://www.terraform.io) Terraform-Plugin-SDK/2.5.0 terraform-provider-google/dev
Content-Type: application/json
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2021-04-13T16:03:05.767+0200
2021-04-13T16:03:06.283+0200 [INFO]  plugin.terraform-provider-google_v3.64.0_x5: 2021/04/13 16:03:06 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 400 Bad Request
Alt-Svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Tue, 13 Apr 2021 14:03:06 GMT
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0

{
  "error": {
    "code": 400,
    "message": "Invalid value at 'force' (TYPE_BOOL), \"\"",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "force",
            "description": "Invalid value at 'force' (TYPE_BOOL), \"\""
          }
        ]
      }
    ]
  }
}

Panic Output

Expected Behavior

Tag template to be deleted and recreated (preferrably updated, but that is covered by #6574.

Actual Behavior

No changes, received 400 bad request:

Error: Error when reading or editing TagTemplate: googleapi: Error 400: Invalid value at 'force' (TYPE_BOOL), ""
Details:
[
  {
    "@type": "type.googleapis.com/google.rpc.BadRequest",
    "fieldViolations": [
      {
        "description": "Invalid value at 'force' (TYPE_BOOL), \"\"",
        "field": "force"
      }
    ]
  }
]

Steps to Reproduce

  1. Create a tag template with fields
  2. terraform apply
  3. Modify a field, setting e.g. is_required from true to false
  4. terraform apply

Important Factoids

References

@ghost ghost added the bug label Apr 13, 2021
@geirsagberg
Copy link
Contributor Author

This seems to happen if force_delete is not set to anything when the tag template is created. This should probably default to false.

@geirsagberg
Copy link
Contributor Author

Interesting comment from the API reference:

Parameters

force | booleanRequired. Currently, this field must always be set to true. This confirms the deletion of this field from any tags using this field. force = false will be supported in the future.

@geirsagberg
Copy link
Contributor Author

Which means that force_delete should for now probably default to true, as it is the only supported value?

@edwardmedia edwardmedia self-assigned this Apr 13, 2021
@edwardmedia
Copy link
Contributor

@geirsagberg yes, below is the doc that specifies what to do. Please close the issue if it is no longer an issue.

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/data_catalog_tag_template#force_delete

@geirsagberg
Copy link
Contributor Author

I would still say it is a bug if the field is not required and the default (empty string) will never work?

@jamiet-msm
Copy link

Definitely a bug IMO as reported over at #8906

@edwardmedia
Copy link
Contributor

edwardmedia commented Apr 14, 2021

I have opened above PR. We will receive below error message from api if force_delete is not set when delete is requested.

{
  "error": {
    "code": 400,
    "message": "The field force must be set to true in order to delete any tags using this tag template.",
    "status": "INVALID_ARGUMENT"
  }
}

@jamiet-msm
Copy link

@edwardmedia I would have thought the correct fix would be to ensure the correct value gets written to the state file in the first place?

@edwardmedia
Copy link
Contributor

@jamiet-msm not sure if I understand what you suggested. force_delete is an optional field. Users should be able to do as it is. What is the correct value you referred to?

@jamiet-msm
Copy link

@edwardmedia Apologies for not explaining clearly. The problem that I elucidated at #8906 is that if force_delete is not specified in the terraform configuration then the literal value null is written into the state file. null is an invalid value for a boolean and hence why error:

Error: Error when reading or editing TagTemplate: googleapi: Error 400: Invalid value at 'force' (TYPE_BOOL), ""
Details:
[
  {
    "@type": "type.googleapis.com/google.rpc.BadRequest",
    "fieldViolations": [
      {
        "description": "Invalid value at 'force' (TYPE_BOOL), \"\"",
        "field": "force"
      }
    ]
  }
]

occurs when we try to deploy. Thus, if force_delete is not specified in the terraform configuration then I think one of two things should happen:

  1. force_delete should not get written to the state file
  2. The correct default value (whatever that is - the docs do not specify what the default value should be) should be written to the state file.

In summary, my point is that the provider should prevent the problem from occurring in the first place rather than trying to handle it after the problem has occurred.

@jamiet-msm
Copy link

One other issue (although its a minor one) is that the error message:

[
  {
    "@type": "type.googleapis.com/google.rpc.BadRequest",
    "fieldViolations": [
      {
        "description": "Invalid value at 'force' (TYPE_BOOL), \"\"",
        "field": "force"
      }
    ]
  }
]

refers to a field called force when in actual fact the argument is called force_delete

@ghost
Copy link

ghost commented May 16, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators May 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.