How can I view the entire, non-truncated error message emitted by a provider?

Hey everyone. I’m new to Terraform and evaluating it for my needs. So far so good, other than one glaring issue: some error messages are completely unactionable. This may or may not be an actual Terraform issue; it might be an Azure (azurerm) provider issue, databricks provider issue, or issue with Azure itself. Here’s the error message when using terraform apply:

Could not launch cluster due to cloud provider failures. azure_error_code: OperationNotAllowed, azure_error_message: Operation could not be completed as it results in exceeding approved Total Regio… Please see Databricks REST API reference for more details

Here’s the scenario. I’m using Azure and trying to set up a Databricks workspace and cluster. I’m using the official Databricks provider to configure the cluster. The actual error is that I’m exceeding the 4 vCPU limit per-region that Azure free-tier accounts are limited to. To figure this out, I had to log in to the Databricks workspace UI, navigate to the cluster, and look at the log. In there, I could see the entire message.

To me, this is something that should be shown at the terraform apply stage. I tried turning on trace logging, but the trace log is also truncated.

I’m not entirely sure where the issue lies, but before I go down the route of creating a GitHub issue, I figured I’d ask here to see if I’m doing anything wrong.

Thanks in advance!

Hi @gerryhernandez,

From Terraform Core’s perspective, the only modification it makes to diagnostic messages returned from providers is to attempt to identify a location in the configuration to attribute them to, which is ideally a particular argument but is more often just the particular resource that raised it, because providers are often surfacing errors from underlying APIs that don’t provide machine-readable information about what aspect of the request was incorrect.

Based on the partial error message you shared here, and the fact that you saw it also truncated in the trace log, I suspect that this message is being truncated by something either in the provider or upstream from the provider. Given that this seems to be DataBricks intermediating a request to Azure and returning Azure’s message, it’s possible that it’s the remote DataBricks API that is doing the truncation, in which case the full error message would not be available client-side at all.

I don’t see the string azure_error_code anywhere in the DataBricks provider repository, so I have to assume this error message is either coming from the API itself or from whatever Go SDK the provider uses to interact with the DataBricks API.

1 Like

Wow, thanks for digging in so thoroughly! Definitely pointing me in the right direction. Much appreciated.

@gerryhernandez i think we’ve improved error handling for cluster creation errors. Please create PR if you’d like to improve it :slight_smile:

You may also use a combination of TF_LOG=DEBUG & DEBUG_TRUNCATE_BYTES=1024 to see more error content in debug logs.

@apparentlymart i wonder if other providers do the same with error logs :slight_smile: