Closed blbradley closed 1 year ago
I had a quick look at this as I also noticed no raw API error messages at some resources.
It seems that the Bitbucket Client that is being used (which is not used for all the resources), sometimes returns a custom/unmarshalled error object instead of the basic error
object. This custom error object contains properties which hold the actual API error, and these properties are basically never accessed in the Terraform resource.
It was able to fix this by returning two errors: one error for internal errors and one for explicitly caught HTTP (Bitbucket) errors. Then I can simply handle the HTTP error in the Terraform resource code:
if httpErr != nil {
return diag.Errorf("%s: %s", httpErr.Error(), string(httpErr.Body()))
}
Which results JSONfied result:
│ Error: 400 Bad Request: {"type": "error", "error": {"message": "kind require_passing_builds_to_merge requires value"}} │ │ with bitbucket_branch_restriction.development, │ on example.tf line 13, in resource "bitbucket_branch_restriction" "development": │ 13: resource "bitbucket_branch_restriction" "development" { │
I can see if I can directly output the “error” value, so we get:
│ Error: 400 Bad Request: "kind require_passing_builds_to_merge requires value"
Just wanted to share my first findings :) This certainly hits more resources, so looking at how I can structure this.
@DrFaust92 I see there are also HTTP calls being done directly from Terraform. Had it been an idea to deprecate the bitbucket/client.go
of this repo in place for explicit https://github.com/DrFaust92/bitbucket-go-client calls?
thanks @Nkmol for looking into this. i wish to deprecate the raw http requests but the go client is not working (pagination doesnt always, work, responses are incorrect /: this mostly stems for the raw swagger spec)
Terraform Version
Affected Resource(s)
Please list the resources as a list, for example:
If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.
Expected Behavior
What should have happened?
provider version 2.4.1 and terraform 0.14.11
Actual Behavior
provider version 2.21.3 and terraform 0.15.5
This is more difficult to debug.