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

Error "invalid input: handler #0: URL is not valid" when updating handler in webhook resource #476

Closed
ribbybibby opened this issue Jun 6, 2022 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@ribbybibby
Copy link

Describe the bug
I receive the following error when updating an existing handler block in a _webhook resource (like artifactory_artifact_webhook):

│ Error:
│ 400 PUT https://<HOST>/event/api/v1/subscriptions/<WEBHOOK>
│ {"errors":[{"message":"invalid input: handler #0: URL is not valid","status":400}]}

It seems to me like the PUT request is sending two handlers: the new configuration and then an empty default configuration.

To reproduce this issue you can follow these steps.

  1. Apply this snippet
terraform {
  required_providers {
    artifactory = {
      source  = "registry.terraform.io/jfrog/artifactory"
      version = "6.9.1"
    }
  }
}

provider "artifactory" {
  url = "<YOUR ARTIFACTORY>"
}


resource "artifactory_artifact_webhook" "foobar" {
  key = "foobar"

  event_types = ["deployed"]

  criteria {
    any_local  = true
    any_remote = false

    repo_keys = []
  }

  handler {
    custom_http_headers = {
      "Authorization" = "Bearer barfoo"
    }

    url = "https://example.com"
  }
}
  1. Update the header value to be Bearer changed or make some other change to the handler block.
  2. Apply and observe error:
artifactory_artifact_webhook.foobar: Refreshing state... [id=foobar]

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:

  # artifactory_artifact_webhook.foobar will be updated in-place
  ~ resource "artifactory_artifact_webhook" "foobar" {
        id          = "foobar"
        # (3 unchanged attributes hidden)


      - handler {
          - custom_http_headers = {
              - "Authorization" = "Bearer barfoo"
            } -> null
          - url                 = "https://example.com" -> null
        }
      + handler {
          + custom_http_headers = {
              + "Authorization" = "Bearer changed"
            }
          + url                 = "https://example.com"
        }
        # (1 unchanged block hidden)
    }

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

artifactory_artifact_webhook.foobar: Modifying... [id=foobar]
╷
│ Error:
│ 400 PUT https://<HOST>/event/api/v1/subscriptions/foobar
│ {"errors":[{"message":"invalid input: handler #0: URL is not valid","status":400}]}
│
│   with artifactory_artifact_webhook.foobar,
│   on main.tf line 15, in resource "artifactory_artifact_webhook" "foobar":
│   15: resource "artifactory_artifact_webhook" "foobar" {
│

Artifactory version: 7.35.2
Provider version: 6.9.1
Terraform version: v1.1.9

Expected behavior
I wouldn't expect an error.

Additional context
This issue sounds related: https://discuss.hashicorp.com/t/using-typeset-in-provider-always-adds-an-empty-element-on-update/18566

@ribbybibby ribbybibby added the bug Something isn't working label Jun 6, 2022
@alexhung
Copy link
Member

alexhung commented Jun 6, 2022

Thanks, we will look into this.

@alexhung
Copy link
Member

alexhung commented Jun 7, 2022

@ribbybibby I can confirm this issue. Looks like it is related to the link you included.

@chb0github
Copy link
Contributor

I am putting together a test case, and so it looks like you're able to create the first webhook without an issue, but when you update the webhook bearer token then this occurs

@alexhung alexhung assigned chb0github and unassigned alexhung Jun 14, 2022
chb0github pushed a commit that referenced this issue Jun 30, 2022
chb0github pushed a commit that referenced this issue Jun 30, 2022
chb0github pushed a commit that referenced this issue Jul 1, 2022
chb0github added a commit that referenced this issue Jul 1, 2022
GH-476 - simpler filter fixes the issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants