Azure-sdk-for-go: v26.7 -> v28.1 seems to break List() service principals

Created on 30 Apr 2019  路  8Comments  路  Source: Azure/azure-sdk-for-go

Bug Report

  • import path of package in question, e.g. .../services/compute/mgmt/2018-06-01/compute
    "github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
  • SDK version e.g. master, latest, 18.1.0
    upgrade was from v26.7 to v28.1

  • output of go version

[08:28:25] kt@snowbook:~/hashi/tf/azure/azurerm鈻竤dk/v28.0.0$ go version
go version go1.12.4 darwin/amd64
  • What happened?
    we updated the SDK to the latest, fixed the build and tests started to fail:
[08:25:08] kt@snowbook:~/hashi/tf/azure/azurerm鈻竤dk/v28.0.0$ testazure TestAccDataSourceAzureRMSnapshot_encryption
==> Fixing source code with gofmt...
# This logic should match the search logic in scripts/gofmtcheck.sh
find . -name '*.go' | grep -v vendor | xargs gofmt -s -w
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./azurerm -v -test.run=TestAccDataSourceAzureRMSnapshot_encryption -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccDataSourceAzureRMSnapshot_encryption
=== PAUSE TestAccDataSourceAzureRMSnapshot_encryption
=== CONT  TestAccDataSourceAzureRMSnapshot_encryption
--- FAIL: TestAccDataSourceAzureRMSnapshot_encryption (3.94s)
    testing.go:568: Step 0 error: errors during refresh:

        Error: Error listing Service Principals: autorest.DetailedError{Original:(*errors.errorString)(0xc0008be750), PackageType:"graphrbac.ServicePrincipalsClient", Method:"List", StatusCode:200, Message:"Failure responding to request", ServiceError:[]uint8(nil), Response:(*http.Response)(0xc000a8b9e0)}

          on /var/folders/bc/2t9ylvbn4lj1_nzj7bxj2kzc0000gn/T/tf-test589194983/main.tf line 2:
          (source code not available)


FAIL
FAIL    github.com/terraform-providers/terraform-provider-azurerm/azurerm   3.988s
make: *** [testacc] Error 1
[08:26:15] kt@snowbook:~/hashi/tf/azure/azurerm鈻竤dk/v28.0.0$

the code there was not changed at all during the upgrade.

  • What did you expect or want to happen?
    the test to pass

  • How can we reproduce it?
    run the above azure test

  • Anything we should know about your environment.
    nope, fails locally in CI and on co workers computers.

this is blocking us from releasing the cosmos resources @jhendrixMSFT

customer specs

Most helpful comment

All 8 comments

@katbyte do you have the response body? You can enable debug logging to dump it to stderr.

@jhendrixMSFT from charles:

{  
   "odata.metadata":"https://graph.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/$metadata#directoryObjects",
   "value":[  
      {  
         "odata.type":"Microsoft.DirectoryServices.ServicePrincipal",
         "objectType":"ServicePrincipal",
         "objectId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
         "deletionTimestamp":null,
         "accountEnabled":true,
         "addIns":[  

         ],
         "alternativeNames":[  

         ],
         "appDisplayName":"Terraform Acceptance Tests",
         "appId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
         "applicationTemplateId":null,
         "appOwnerTenantId":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
         "appRoleAssignmentRequired":false,
         "appRoles":[  

         ],
         "displayName":"Terraform Acceptance Tests",
         "errorUrl":null,
         "homepage":"http://terra.form",
         "informationalUrls":{  
            "termsOfService":null,
            "support":null,
            "privacy":null,
            "marketing":null
         },
         "keyCredentials":[  

         ],
         "logoutUrl":null,
         "notificationEmailAddresses":[  

         ],
         "oauth2Permissions":[  
            {  
               "adminConsentDescription":"Allow the application to access Terraform Acceptance Tests on behalf of the signed-in user.",
               "adminConsentDisplayName":"Access Terraform Acceptance Tests",
               "id":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
               "isEnabled":true,
               "type":"User",
               "userConsentDescription":"Allow the application to access Terraform Acceptance Tests on your behalf.",
               "userConsentDisplayName":"Access Terraform Acceptance Tests",
               "value":"user_impersonation"
            }
         ],
         "passwordCredentials":[  

         ],
         "preferredSingleSignOnMode":null,
         "preferredTokenSigningKeyEndDateTime":null,
         "preferredTokenSigningKeyThumbprint":null,
         "publisherName":"Default Directory",
         "replyUrls":[  
            "http://terra.form"
         ],
         "samlMetadataUrl":null,
         "samlSingleSignOnSettings":null,
         "servicePrincipalNames":[  
            "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "https://xxxx/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
         ],
         "servicePrincipalType":"Application",
         "signInAudience":"AzureADMyOrg",
         "tags":[  
            "WindowsAzureActiveDirectoryIntegratedApp"
         ],
         "tokenEncryptionKeyId":null
      }
   ]

Thanks! The problem appears to be this

"accountEnabled":true,

According to the swagger this is supposed to be a string, and from the history it's always been that way. My guess is that the endpoint changed but the swagger didn't, I'm going to follow up on this.

Correction, this is a regression introduced in the following commit.
https://github.com/Azure/azure-rest-api-specs/commit/5a3fb7cc7cb3adb16f9da603e91c1c55048129d1#diff-143a2f7b8a78aa4d5b81df25bc12f77a

One thing I don't understand yet is why the underlying error message "json: cannot unmarshal bool into Go value of type string" is lost in the output.

I think it may have to do with it is a List() command, i've noticed a .Get() will show the unmarshal error.

I just ran into this as well, going from 26.7 -> 27.0, with:

        result, err := c.provider.CreateServicePrincipal(ctx, graphrbac.ServicePrincipalCreateParameters{
            AppID: app.AppID,
            AccountEnabled: to.StringPtr("true"),
        })

I'm getting back: graphrbac.ServicePrincipalsClient#Create: Failure responding to request: StatusCode=201 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal bool into Go value of type string'

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sozercan picture sozercan  路  3Comments

drosseau picture drosseau  路  4Comments

mbfrahry picture mbfrahry  路  4Comments

yannart picture yannart  路  3Comments

CecileRobertMichon picture CecileRobertMichon  路  4Comments