Bug Report
I'm using the Azure SDK for Go (v3.0.0-beta.2), specifically the armauthorization package, and facing an issue when calling client.Create with the RoleAssignmentScheduleRequestsClient. The problem seems to be with the scope parameter, but I'm unsure of the correct format. This occurs with Go version 1.23.1, and the API response isn't unmarshalling as expected.
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3 v3.0.0-beta.2
What happened?
When calling a function from the armauthorization/v3 package, specifically when interacting with the RoleAssignmentScheduleRequestsClient, an error occurs during the JSON unmarshalling process. The error message is:
2024/12/28 22:06:24 main.go: unmarshalling type *runtime.requestError: json: cannot unmarshal string into Go value of type runtime.requestError
What did you expect or want to happen?
The API response should be unmarshalled correctly into the appropriate Go struct, without any errors.
How can we reproduce it?
It appears that the issue is related to the scope, but I'm unsure if there is any documentation detailing the correct format for the scope. The error occurs after the client.Create function is called, as indicated in the logs.
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3"
"k8s.io/utils/ptr"
)
func main() {
// Set up the credentials to authenticate with Azure
cred, err := azidentity.NewDeviceCodeCredential(&azidentity.DeviceCodeCredentialOptions{
TenantID: "dummy-tenant-id-1234-5678-91011-abcdefg", // Replace with dummy tenant ID
ClientOptions: policy.ClientOptions{
Cloud: cloud.AzurePublic,
},
UserPrompt: func(ctx context.Context, message azidentity.DeviceCodeMessage) error {
fmt.Println(message.Message) // Print the device code prompt
return nil
},
})
if err != nil {
log.Fatal(err)
}
// Create the client for role assignment schedule requests
client, err := armauthorization.NewRoleAssignmentScheduleRequestsClient(cred, nil)
if err != nil {
log.Fatal(err)
}
// Dummy values for principalID, roleDefinitionID, and scope
principalID := "dummy-principal-id-1234-5678-91011"
roleDefinitionID := "/providers/Microsoft.Authorization/roleDefinitions/dummy-role-id-1234-5678-91011"
justification := "dummy justification"
scope := "/providers/Microsoft.Management/managementGroups/dummy-management-group-id"
// Make the request to create a role assignment schedule
resp, err := client.Create(
context.Background(),
scope,
"dummy-role-assignment-request-id", // Dummy request ID
armauthorization.RoleAssignmentScheduleRequest{
Properties: &armauthorization.RoleAssignmentScheduleRequestProperties{
PrincipalID: ptr.To(principalID),
RequestType: ptr.To(armauthorization.RequestTypeSelfActivate),
RoleDefinitionID: ptr.To(roleDefinitionID),
Justification: ptr.To(justification),
Scope: ptr.To(scope),
ScheduleInfo: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfo{
Expiration: &armauthorization.RoleAssignmentScheduleRequestPropertiesScheduleInfoExpiration{
Type: to.Ptr(armauthorization.TypeAfterDuration),
Duration: to.Ptr("PT30M"),
},
StartDateTime: to.Ptr(time.Now()),
},
},
}, nil,
)
if err != nil {
log.Fatal(err)
}
// If successful, print the response
fmt.Printf("Role assignment schedule request created successfully: %+v\n", resp)
}
Anything we should know about your environment?
Nothing specific, I'm just running the code I provided on Gentoo Linux.
Bug Report
I'm using the Azure SDK for Go (
v3.0.0-beta.2), specifically thearmauthorizationpackage, and facing an issue when callingclient.Createwith the RoleAssignmentScheduleRequestsClient. The problem seems to be with the scope parameter, but I'm unsure of the correct format. This occurs with Go version1.23.1, and the API response isn't unmarshalling as expected.What happened?
When calling a function from the
armauthorization/v3package, specifically when interacting with theRoleAssignmentScheduleRequestsClient, an error occurs during the JSON unmarshalling process. The error message is:What did you expect or want to happen?
The API response should be unmarshalled correctly into the appropriate Go struct, without any errors.
How can we reproduce it?
It appears that the issue is related to the scope, but I'm unsure if there is any documentation detailing the correct format for the scope. The error occurs after the
client.Createfunction is called, as indicated in the logs.Anything we should know about your environment?
Nothing specific, I'm just running the code I provided on Gentoo Linux.