-
Notifications
You must be signed in to change notification settings - Fork 848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[v11.2.2-beta] JSON unmarshalling error in monitor.AlertRuleResource #951
Comments
@dominik-lekse This appears to be fixed in v12 as I can't repro this issue with it. Is it possible for you to move to v12? Also note that you want to be using content from under the services directory, the stuff under the arm directory has been deprecated. |
Hi @jhendrixMSFT, thanks for testing this for v12. I think the terraform provider will upgrade to v12 during this month so that I can test it again. Shall we keep this issue open until then? |
@dominik-lekse We can keep this open until you've had a chance to validate with v12 if that helps. |
Hi @jhendrixMSFT, I can confirm that using the latest v12 SDK, this error is fixed. Many thanks. |
Fantastic, thanks for letting me know. :) |
While working on the pull request hashicorp/terraform-provider-azurerm#478, I encountered a JSON unmarshalling error when using the methods
AlertRulesClient.CreateOrUpdate
orAlertRulesClient.Get
. Both methods unmarshal JSON to amonitor.AlertRuleResource
instance.Using the method
AlertRulesClient.CreateOrUpdate
provided bymonitor.AlertRulesClient
raises a runtime error due invalid memory address or nil pointer dereference. The error occurs during marshalling the JSON response in Get or CreateOrUpdate. The reason appears to be that the fieldAlertRule
of typeAlertRuleResource
is generated as an embedded field. This leads tonil
being passed to monitor.(*AlertRule).UnmarshalJSON when unmarshalling and causes the runtime error.Changing the field
AlertRule
to an explicitly defined field as shown in the following excerpt solves the problem.This error occurs in version
v11.2.2-beta
of the azure-sdk-for-go which is used by the most recent version of the Terraform AzureRM provider. Although not tested, I assume that the most recent version of the azure-sdk-for-go encounters this error since the definition of AlertRuleResource inarm/monitor/models.go
has not changed since v11.2.2-beta.The text was updated successfully, but these errors were encountered: