hashicorp/terraform · error
retrieving : model was nil
Error message
retrieving %s: model was nil
What it means
Thrown by Azure buildClient when storageAccountsClient.GetProperties returned no error but resp.Model is nil, i.e. the SDK handed back a 'success' response with no payload model. This is an SDK contract violation or an unexpected empty body from ARM, not a normal user-config error.
Solutions
- Report it as a bug against Terraform/go-azure-sdk with the storage account kind and the ARM response, since the contract was violated.
- Update to a Terraform version that links a go-azure-sdk release matching the current ARM storage API.
- Retry once; if ARM returned an intermittent empty body it may succeed on a second call.
- If you maintain the SDK client, ensure GetProperties always sets Model on a 2xx response or returns an error instead.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// Cannot truly validate from outside; at most, retry once on this SDK-contract failure. // Real prevention is on the SDK side: ensure GetProperties sets Model on 2xx.
Type guard
null
Try / catch
client, err := azure.NewClient(ctx, cfg)
if err != nil && strings.Contains(err.Error(), "model was nil") {
// retry once; if it persists, report an SDK/ARM bug
} Prevention
- Keep go-azure-sdk aligned with the Terraform release so the response model is populated correctly.
- If you maintain a mock storage client for tests, always populate resp.Model on 2xx to mirror ARM.
- Report persistent occurrences with the storage account kind and ARM response, since this indicates an API/SDK mismatch.
When it happens
Trigger: The go-azure-sdk storageaccounts.GetProperties call returns resp=nil-model-but-no-error. This happens with a version skew between the linked go-azure-sdk and the ARM API shape, an ARM response that returned 200 with an empty body, or a custom/mock storage client that does not populate Model.
Common situations: Running a Terraform build against an incompatible go-azure-sdk revision; ARM returning an unusual response for a preview/special storage account; a test double that forgets to set Model. End users on released Terraform almost never hit this unless the ARM service misbehaves.
Related errors
- building Storage Accounts client: %+v
- retrieving : %+v
- populating details for
- retrieving key for Storage Account
- subscription id not specified
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/58ac62176d2169d2.
Report an issue: GitHub.
Appendix: source
Thrown at internal/backend/remote-state/azure/api_client.go:109
if config.SubscriptionID == "" {
return nil, fmt.Errorf("subscription id not specified")
}
// Setup the SA client.
client.storageAccountsClient, err = storageaccounts.NewStorageAccountsClientWithBaseURI(config.AuthConfig.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building Storage Accounts client: %+v", err)
}
client.configureClient(client.storageAccountsClient.Client, resourceManagerAuth)
// Populating the storage account detail
storageAccountId := commonids.NewStorageAccountID(config.SubscriptionID, config.ResourceGroupName, client.storageAccountName)
resp, err := client.storageAccountsClient.GetProperties(ctx, storageAccountId, storageaccounts.DefaultGetPropertiesOperationOptions())
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", storageAccountId, err)
}
if resp.Model == nil {
return nil, fmt.Errorf("retrieving %s: model was nil", storageAccountId)
}
client.accountDetail, err = populateAccountDetails(storageAccountId, *resp.Model)
if err != nil {
return nil, fmt.Errorf("populating details for %s: %+v", storageAccountId, err)
}
}
return &client, nil
}
func (c *Client) getBlobClient(ctx context.Context) (bc *blobs.Client, err error) {
if c.blobsClient != nil {
return c.blobsClient, nil
}
defer func() {
if err == nil {
c.blobsClient = bcView on GitHub (pinned to d32a084675)