pactflow / terraform-provider-pact

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

fix: errors in some API resources weren't being propagated #32

Closed mefellows closed 1 year ago

mefellows commented 1 year ago

Fix for the following fatal error:

2023-03-17T00:04:04.601Z [DEBUG] plugin.terraform-provider-pact: 2023/03/17 00:04:04 [DEBUG] response for request: &{POST https://xyz.pactflow.io/admin/system-accounts HTTP/1.1 1 1 map[Accept:[application/hal+json, application/json] Authorization:[Bearer AATaTzDgZmrxyj9WyAwCkg] Content-Type:[application/json] User-Agent:[go-pact/v0.9.0]] {} 0x82df20 118 [] false xyz.pactflow.io map[] map[] <nil> map[]   <nil> <nil> <nil> 0xc00011e000} resp: &{400 Bad Request 400 HTTP/2.0 2 0 map[Content-Length:[85] Content-Type:[application/hal+json;charset=utf-8] Date:[Fri, 17 Mar 2023 00:04:04 GMT] Server:[Webmachine-Ruby/1.6.0 Rack/1.3] Strict-Transport-Security:[max-age=63072000; includeSubDomains; preload] Vary:[Accept] X-Content-Type-Options:[nosniff] X-Pact-Broker-Git-Sha:[e0c525cf] X-Pact-Broker-Version:[2.106.0] X-Pactflow-Git-Sha:[5cad6c1c4] X-Request-Id:[203cdc79be070b6f06af25cef6ff80e2]] {0xc000621e00} 85 [] false false map[] 0xc0001a6700 0xc00085a0b0}
2023-03-17T00:04:04.601Z [DEBUG] plugin.terraform-provider-pact: 2023/03/17 00:04:04 [DEBUG] handling error response: {"errors":{"name":["A system account with name 'Bender Rodríguez' already exists"]}}
panic: interface conversion: interface {} is nil, not string

The error is now properly bubbled back up to the user:

Screen Shot 2023-03-17 at 12 08 24 pm