{"record":{"id":"58ac62176d2169d2","repo":"hashicorp/terraform","slug":"retrieving-s-model-was-nil","errorCode":null,"errorMessage":"retrieving %s: model was nil","messagePattern":"retrieving (.+?): model was nil","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/azure/api_client.go","lineNumber":109,"sourceCode":"\t\tif config.SubscriptionID == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"subscription id not specified\")\n\t\t}\n\n\t\t// Setup the SA client.\n\t\tclient.storageAccountsClient, err = storageaccounts.NewStorageAccountsClientWithBaseURI(config.AuthConfig.Environment.ResourceManager)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"building Storage Accounts client: %+v\", err)\n\t\t}\n\t\tclient.configureClient(client.storageAccountsClient.Client, resourceManagerAuth)\n\n\t\t// Populating the storage account detail\n\t\tstorageAccountId := commonids.NewStorageAccountID(config.SubscriptionID, config.ResourceGroupName, client.storageAccountName)\n\t\tresp, err := client.storageAccountsClient.GetProperties(ctx, storageAccountId, storageaccounts.DefaultGetPropertiesOperationOptions())\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"retrieving %s: %+v\", storageAccountId, err)\n\t\t}\n\t\tif resp.Model == nil {\n\t\t\treturn nil, fmt.Errorf(\"retrieving %s: model was nil\", storageAccountId)\n\t\t}\n\t\tclient.accountDetail, err = populateAccountDetails(storageAccountId, *resp.Model)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"populating details for %s: %+v\", storageAccountId, err)\n\t\t}\n\t}\n\n\treturn &client, nil\n}\n\nfunc (c *Client) getBlobClient(ctx context.Context) (bc *blobs.Client, err error) {\n\tif c.blobsClient != nil {\n\t\treturn c.blobsClient, nil\n\t}\n\n\tdefer func() {\n\t\tif err == nil {\n\t\t\tc.blobsClient = bc","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/azure/api_client.go#L91-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Cannot truly validate from outside; at most, retry once on this SDK-contract failure.\n// Real prevention is on the SDK side: ensure GetProperties sets Model on 2xx.","typeGuard":"null","tryCatchPattern":"client, err := azure.NewClient(ctx, cfg)\nif err != nil && strings.Contains(err.Error(), \"model was nil\") {\n    // retry once; if it persists, report an SDK/ARM bug\n}","preventionTips":["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."],"tags":["azure","backend","sdk","invariant","storage-account","arm"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}