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

[Bug] The ibm_resource_tag does not check the response on api tags calls #5635

Closed
luiof opened this issue Sep 11, 2024 · 1 comment · Fixed by #5641
Closed

[Bug] The ibm_resource_tag does not check the response on api tags calls #5635

luiof opened this issue Sep 11, 2024 · 1 comment · Fixed by #5641
Labels
service/Global Tagging Issues related to Global Tagging service/Resource Management Issues related to Resource Manager or Resource controller Issues

Comments

@luiof
Copy link
Contributor

luiof commented Sep 11, 2024

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 other comments that do not add relevant new information or questions, 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

Terraform CLI and Terraform IBM Provider Version

Terraform v1.9.5
on darwin_arm64
+ provider registry.terraform.io/ibm-cloud/ibm v1.69.1

Affected Resource(s)

  • ibm_resource_tag

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "ibm_resource_tag" "tag" {
  resource_id = "crn:v1:bluemix:public:cloud-object-storage:global:a/999f9cb9bbc99999ab9a0f999e9b999c:df999d99-9c99-9d9d-9dce-999cd999da9c::"
  tags        = ["env:dev", "cpu:4"]
}

Debug Output

Panic Output

Expected Behavior

When we provision a ibm_resource_tag and there is an error on the attach call we can have a response with http code 200 and a json like:

{
  "results": [
    {
      "resource_id": "crn:v1:bluemix:public:cloud-object-storage:global:a/999f9cb9bbc99999ab9a0f999e9b999c:df999d99-9c99-9d9d-9dce-999cd999da9c::",
      "isError": "true",
      "is_error": true,
      "response": "RESOURCE_ACCOUNT_OUT_OF_SCOPE",
      "message": "The resource account is out of scope",
      "code": "GST919E",
      "level": "error",
      "httpCode": 400,
      "description": "You should not perform a tagging operation on a resource in another account"
    }
  ]
}

or like:

{
  "results": [
    {
      "resource_id": "crn:v1:bluemix:public:cloud-object-storage:global:a/999f9cb9bbc99999ab9a0f999e9b999c:df999d99-9c99-9d9d-9dce-999cd999da9c::",
      "isError": "true",
      "is_error": true,
      "response": "RESOURCE_DOC_NOT_FOUND",
      "message": "The resource with the crn crn:v1:bluemix:public:cloud-object-storage:global:a/999f9cb9bbc99999ab9a0f999e9b999c:df999d99-9c99-9d9d-9dce-999cd999da9c:: is not found",
      "code": "GST924E",
      "level": "error",
      "httpCode": 404
    }
  ]
}

With the above response, we expect to see an error on the terraform plan/apply.

Actual Behavior

The expected behavior does not occur since the code here does not check the results:

image

This occurs in multiple uses cases:

  • in apply
  • in destroy
  • when we pass a CRN of a not existing resources
  • when there are other generic errors in the response

Logs:

Zip archive with the code snippet:
Archive.zip

Steps to Reproduce

  1. terraform init
  2. terraform plan
  3. terraform apply
  4. terraform destroy

Important Factoids

References

  • #0000
@github-actions github-actions bot added service/Global Tagging Issues related to Global Tagging service/Resource Management Issues related to Resource Manager or Resource controller Issues labels Sep 11, 2024
@luiof luiof changed the title The ibm_resource_tag does not check the response on attaching tags The ibm_resource_tag does not check the response on api tags calls Sep 11, 2024
@luiof luiof changed the title The ibm_resource_tag does not check the response on api tags calls BugThe ibm_resource_tag does not check the response on api tags calls Sep 11, 2024
@luiof luiof changed the title BugThe ibm_resource_tag does not check the response on api tags calls [Bug] The ibm_resource_tag does not check the response on api tags calls Sep 11, 2024
@luiof
Copy link
Contributor Author

luiof commented Sep 13, 2024

PR to fix this: #5641

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/Global Tagging Issues related to Global Tagging service/Resource Management Issues related to Resource Manager or Resource controller Issues
Projects
None yet
1 participant