pactflow / terraform-provider-pact

Terraform provider for Pact Broker (and Pactflow)
https://pactflow.io
MIT License
24 stars 4 forks source link

Bug: repository url should be escaped #18

Closed mefellows closed 2 years ago

mefellows commented 2 years ago

Bug report via https://pact-foundation.slack.com/archives/C02NN7XSHDM/p1641776812008000

The first change is changing the repository_url of one of the applications. terraform apply shows:

 # pact_application.fruit will be updated in-place
  ~ resource "pact_application" "fruit" {
        id             = "Fruit"
        name           = "Fruit"
      ~ repository_url = "https://github.com/company/admin" -> "https://github.dev.xero.com/Xero/QE-Pactflow-Management"
    }

After reporting a successful apply command, the resource still has the old url. Looking at the audit events, I found that for some reason the PATCH request has the wrong path, looks like an escaped formatting sequence issue maybe (%25s)?

{
    "uuid": "O2VY9vwUAaOBDJMDuOrLmg",
    "timestamp": "2021-12-10T00:52:32.201+00:00",
    "type": "pacticipant",
    "userUUID": "56b15671-a578-4bc6-a858-b4792433ba3e",
    "name": "Jonatan Jaworski",
    "tokenUUID": "FqhmJO3ulus-mJ99hGSdKA",
    "payload": {
        "path": "/pacticipants/%25s",
        "queryString": "",
        "method": "PATCH",
        "userAgent": "go-pact/0.0.1",
        "referer": null,
        "remoteHost": null,
        "remoteAddress": "10.2.1.48",
        "requestId": "03c91bf3e3345c024129f7d057d7fe28"
    },
    "response": {
        "status": 200
    }
}

As a result, I get a new application created ("%25s") instead of updating the existing one. I don't really know when it goes wrong like that.

I also found a log that goes:

2022-01-10T11:55:37.780+1300 [WARN]  Provider "registry.terraform.io/pactflow/pact" produced an unexpected new value for pact_application.fruit during refresh.
      - .repository_url: was cty.StringVal("https://github.dev.xero.com/Xero/QE-Pactflow-Management"), but now cty.StringVal("https://github.com/company/admin")

Which to me confirms that TF was expecting the change to be applied when refreshing state but it wasn't.