hashicorp/terraform · error

retrieving %s: model was nil

Error message

retrieving %s: model was nil

What it means

Returned by buildClient when storageAccountsClient.GetProperties returns no error but the response Model is nil. The ARM API returned a successful-looking response with no storage account payload, which is unexpected. The %s is the storage account resource ID.

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 = bc

View on GitHub (pinned to c9def3e214)

Solutions

  1. Retry the operation (can be a transient API anomaly).
  2. Update/upgrade Terraform (and thus the go-azure-sdk storage version) which may handle the response shape correctly.
  3. Report the issue with the storage account resource ID if it persists — likely an SDK/API contract bug.
Defensive patterns

Strategy: retry

Try / catch

client, err := buildClient(ctx, config)
if err != nil && strings.Contains(err.Error(), "model was nil") {
    // retry once; if it persists, report SDK/API version issue
}

Prevention

When it happens

Trigger: The ARM GetProperties call completes without an HTTP/transport error but the deserialized storage account model is nil — an edge case in the API/SDK where a 2xx or empty body yields no model. Very rare; indicates an SDK/API contract issue or an unexpected empty response.

Common situations: An Azure API/SDK version quirk returning an empty body for a valid account; proxy or gateway stripping the response body; an SDK deserialization mismatch after a backend API change.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/58ac62176d2169d2. Report an issue: GitHub.