hashicorp / terraform-provider-softlayer

Terraform SoftLayer provider. Please note: This Terraform provider is archived per our provider archiving process: https://terraform.io/docs/internals/archiving.html
https://www.terraform.io/docs/providers/softlayer/
Mozilla Public License 2.0
1 stars 7 forks source link

Terraform prints error 500 instead of showing actual error #6

Open hashibot opened 7 years ago

hashibot commented 7 years ago

This issue was originally opened by @bondyk as hashicorp/terraform#9241. It was migrated here as part of the provider split. The original body of the issue is below.


Hi,

Terraform prints generic error message instead of the actual message from SoftLayer. In my example underscore char is forbidden to be used in host name. In such case SoftLayer API returns response (code 500) with following payload:

<?xml version="1.0" encoding="iso-8859-1"?>
<methodResponse>
<fault>
 <value>
  <struct>
   <member>
    <name>faultCode</name>
    <value>
     <string>SoftLayer_Exception_Public</string>
    </value>
   </member>
   <member>
    <name>faultString</name>
    <value>
     <string>The hostname and domain must be alphanumeric strings that may be separated by periods '.'.  The only other allowable special character is the dash '-'  However the special characters '.' and '-' may not be consecutive.  Each alphanumeric string separated by a period is considered a label.  Labels must begin and end with an alphanumeric character and must be between 1-63 characters in length.  The last label, the TLD (top level domain) must be between 2-24 alphabetic characters. The TLD label and hostname cannot be solely comprised of digits. The domain portion must consist of least one label followed by a period '.' then ending with the TLD label.  Combining the hostname, followed by a period '.', followed by the domain gives the FQDN (fully qualified domain name), which may not exceed 253 characters in total length.</string>
    </value>
   </member>
  </struct>
 </value>
</fault>
</methodResponse>

If use terraform with the same input data then it prints generic error 500 message.

Terraform Version

v0.7.5-dev

Affected Resource(s)

-softlayer_virtual_guest

Terraform Configuration

resource "softlayer_virtual_guest" "server1" {
    name = "server1_name"
    block_device_template_group_gid = "${var.block_device_template_group_gid}"
    domain = "${var.domain}"
    region = "${var.region}"
    hourly_billing = "${var.hourly_billing}"
    private_network_only = "${var.private_network_only}"
    public_network_speed = "${var.public_network_speed}"
    cpu = "${var.cpu}"
    ram = "${var.ram}"
    local_disk = "${var.local_disk}"
}

Expected Behavior

Terraform should print actual error message instead of showing generic Error 500:

The hostname and domain must be alphanumeric strings that may be separated by periods '.'.  The only other allowable special character is the dash '-'  However the special characters '.' and '-' may not be consecutive.  Each alphanumeric string separated by a period is considered a label.  Labels must begin and end with an alphanumeric character and must be between 1-63 characters in length.  The last label, the TLD (top level domain) must be between 2-24 alphabetic characters. The TLD label and hostname cannot be solely comprised of digits. The domain portion must consist of least one label followed by a period '.' then ending with the TLD label.  Combining the hostname, followed by a period '.', followed by the domain gives the FQDN (fully qualified domain name), which may not exceed 253 characters in total length.

Actual Behavior

Terraform prints Error 500:

Error applying plan:

1 error(s) occurred:

* softlayer_virtual_guest.server1: Error creating virtual guest: softlayer-go: could not SoftLayer_Virtual_Guest#createObject, HTTP error code: '500'

Steps to Reproduce

Run terraform apply with configured SoftLayer provider that has underscore in 'name'

albee-jhoney commented 6 years ago

Let us know, if you face this error in the IBM Cloud provider here: https://github.com/IBM-Cloud/terraform-provider-ibm; docs - https://ibm-cloud.github.io/tf-ibm-docs/