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

Unable to remove or add elements to issue_type_ids list attribute in atlassian_jira_issue_type_scheme resource #102

Open
1 task done
iacabezasbaculima opened this issue Aug 27, 2022 · 0 comments
Labels
bug Addresses a defect in current functionality. jira/issuetypeschemes Issues and PRs that pertain to jira/issuetypeschemes resources.

Comments

@iacabezasbaculima
Copy link
Contributor

iacabezasbaculima commented Aug 27, 2022

Affected Resources

  • atlassian_jira_issue_type_scheme

Terraform CLI and Provider Versions

v0.1.0

Terraform Configuration

na

Expected Behavior

When adding a new issue type to the issue_type_ids attribute, the provider will trigger the update resource method.

The update method should add the new issue type to issue_type_ids as detailed in the Terraform plan.

Similary, the update method should remove an issue type from issue_type_ids using the Terraform plan and state to perform any relevant checks and validations.

Actual Behavior

When applying a configuration to add a new issue type to the issue_type_ids attribute, the provider throws an error inside the update resource method as shown below:

terraform apply
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp.com/edu/hashicups-pf in /Users/iacb/go/bin
│  - openscientia/atlassian in /Users/iacb/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
atlassian_jira_issue_type_scheme.foo: Refreshing state... [id=10243]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # atlassian_jira_issue_type_scheme.foo will be updated in-place
  ~ resource "atlassian_jira_issue_type_scheme" "foo" {
      + default_issue_type_id = (known after apply)
      + description           = (known after apply)
      ~ id                    = "10243" -> (known after apply)
      ~ issue_type_ids        = [
            "10000",
          + "10001",
        ]
        name                  = "foo"
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

atlassian_jira_issue_type_scheme.foo: Modifying... [id=10243]
╷
│ Error: Client Error
│
│   with atlassian_jira_issue_type_scheme.foo,
│   on main.tf line 11, in resource "atlassian_jira_issue_type_scheme" "foo":
│   11: resource "atlassian_jira_issue_type_scheme" "foo" {
│
│ Unable to add issue types to issue type scheme, got error: request failed. Please analyze the request body for more details. Status Code: 404
│ {"errorMessages":["These issue types were not found: 0"],"errors":{}}
╵

When applying a configuration to remove an issue type from the issue_type_ids attribute, the provider completes the update method successfully as shown below. However, the issue type is still present in the resource's API state.

terraform apply
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp.com/edu/hashicups-pf in /Users/iacb/go/bin
│  - openscientia/atlassian in /Users/iacb/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
atlassian_jira_issue_type_scheme.foo: Refreshing state... [id=10243]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # atlassian_jira_issue_type_scheme.foo will be updated in-place
  ~ resource "atlassian_jira_issue_type_scheme" "foo" {
      + default_issue_type_id = (known after apply)
      + description           = (known after apply)
      ~ id                    = "10243" -> (known after apply)
      ~ issue_type_ids        = [
          - "10000",
        ]
        name                  = "foo"
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

atlassian_jira_issue_type_scheme.foo: Modifying... [id=10243]
atlassian_jira_issue_type_scheme.foo: Modifications complete after 1s [id=10243]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Steps to Reproduce

  1. Create atlassian_jira_issue_type_scheme resource with one value in the issue_type_ids attribute:
resource "atlassian_jira_issue_type_scheme" "foo" {
  name           = "foo"
  issue_type_ids = ["10000"]
}
  1. terraform apply
  2. Add another value in the issue_type_ids attribute.
resource "atlassian_jira_issue_type_scheme" "foo" {
  name           = "foo"
  issue_type_ids = ["10000", "10001"]
}
  1. terraform apply. This will throw an error when the provider executes the resource's update method.
  2. Similarly, remove all values in the issue_type_ids attribute.
resource "atlassian_jira_issue_type_scheme" "foo" {
  name           = "foo"
  issue_type_ids = []
}
  1. terraform apply. This will complete without errors but the value is not removed from API state.

How much impact is this issue causing?

High

Logs

No response

Additional Information

This may be fixed by adding the following code fix:

tfval, _ := listValue.ToTerraformValue(ctx)
var new_issue_type_id string
tfval.As(&new_issue_type_id)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@iacabezasbaculima iacabezasbaculima added the bug Addresses a defect in current functionality. label Aug 27, 2022
@github-actions github-actions bot added the jira/issuetypeschemes Issues and PRs that pertain to jira/issuetypeschemes resources. label Aug 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. jira/issuetypeschemes Issues and PRs that pertain to jira/issuetypeschemes resources.
Projects
None yet
Development

No branches or pull requests

1 participant