Skip to content
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

Failed to create an application with the graph service client #9

Closed
aramase opened this issue Nov 8, 2021 · 5 comments · Fixed by #13
Closed

Failed to create an application with the graph service client #9

aramase opened this issue Nov 8, 2021 · 5 comments · Fixed by #13
Assignees
Labels
bug Something isn't working fixed

Comments

@aramase
Copy link

aramase commented Nov 8, 2021

I'm trying to create an app and I see it gets created, but it fails at the deserialization. Here is the sample function:

func GraphClient(tenantID, clientID, clientSecret string) (*graph.Application, error) {
    cred, err := azidentity.NewClientSecretCredential(tenantID, clientID, clientSecret, nil)
    if err != nil {
        return nil, errors.Wrap(err, "failed to create credential")
    }
    auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{"https://graph.microsoft.com/.default"})
    if err != nil {
        return nil, errors.Wrap(err, "failed to create authentication provider")
    }
    adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
    if err != nil {
        return nil, errors.Wrap(err, "failed to create request adapter")
    }
    client := msgraphsdk.NewGraphServiceClient(adapter)
    name := "kiota"
    appOptions := &applications.ApplicationsRequestBuilderPostOptions{
        Body: graph.NewApplication(),
    }
    appOptions.Body.SetDisplayName(&name)
    return client.Applications().Post(appOptions)
}

This is the error i'm getting:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6658e7]
goroutine 1 [running]:
github.com/microsoft/kiota/serialization/go/json.(*JsonParseNode).GetObjectValue(0xc000013460, 0xc000024230)
        /home/anramase/go/pkg/mod/github.com/microsoft/kiota/serialization/go/json@v0.0.0-20211108132630-7da008c70103/json_parse_node.go:161 +0x1a7
github.com/microsoft/kiota/http/go/nethttp.(*NetHttpRequestAdapter).SendAsync(0xc0000c4230, {0x1, 0x0, 0xc000095320, 0xc000095350, {0xc0000bc180, 0x17, 0x18}, 0xc000095290, {0x70b28c, ...}, ...}, ...)
        /home/anramase/go/pkg/mod/github.com/microsoft/kiota/http/go/nethttp@v0.0.0-20211108132630-7da008c70103/nethttp_request_adapter.go:170 +0x158
github.com/microsoftgraph/msgraph-sdk-go/applications.(*ApplicationsRequestBuilder).Post(0xc0000952f0, 0x768ee8)
        /home/anramase/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go@v0.0.3/applications/applications_request_builder.go:166 +0xc2
github.com/aramase/graphsdk/pkg/cloud.GraphClient({0x703c65, 0x300000002}, {0x703ab5, 0xc00003c738}, {0x702bde, 0xc0000001a0})
        /home/anramase/go/src/github.com/aramase/graphsdk/pkg/cloud/graphsdk.go:33 +0x208
main.main()
        /home/anramase/go/src/github.com/aramase/graphsdk/cmd/main.go:21 +0x55

Versions of the sdk being used from go.mod:

	github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0
	github.com/microsoft/kiota/authentication/go/azure v0.0.0-20211108143922-c77efb191939
	github.com/microsoftgraph/msgraph-sdk-go v0.0.3

cc @baywet

@baywet
Copy link
Member

baywet commented Nov 9, 2021

Hi @aramase,
Thanks for reaching out, I have looked into the issue and it seems the deserialization code had several short comings which I have fixed through microsoft/kiota#823 and #13.
Once these pull requests get merged, and you update the dependencies on your side, your snippet will work.
This will probably happen by tomorrow, EOW at latest.

@baywet baywet added bug Something isn't working fixed labels Nov 9, 2021
@aramase
Copy link
Author

aramase commented Nov 10, 2021

@baywet I'm using the following versions with the same code to test the fix:

	github.com/microsoft/kiota/authentication/go/azure v0.0.0-20211110153957-004520ec140f
	github.com/microsoftgraph/msgraph-sdk-go v0.1.1

but still seeing a similar error. Could you confirm if I'm using the correct versions?

Error:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x666537]

goroutine 1 [running]:
github.com/microsoft/kiota/serialization/go/json.(*JsonParseNode).GetTimeValue(0xc0000aa3d0)
	/home/anramase/go/pkg/mod/github.com/microsoft/kiota/serialization/go/json@v0.0.0-20211108132630-7da008c70103/json_parse_node.go:307 +0x57
github.com/microsoftgraph/msgraph-sdk-go/models/microsoft/graph.(*DirectoryObject).GetFieldDeserializers.func1({0x6a8f80, 0xc00040ee10}, {0x76a8a0, 0x0})
	/home/anramase/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go@v0.1.1/models/microsoft/graph/directory_object.go:33 +0x33
github.com/microsoft/kiota/serialization/go/json.(*JsonParseNode).GetObjectValue(0xc0004f31b0, 0xc000454070)
	/home/anramase/go/pkg/mod/github.com/microsoft/kiota/serialization/go/json@v0.0.0-20211108132630-7da008c70103/json_parse_node.go:163 +0x22e
github.com/microsoft/kiota/http/go/nethttp.(*NetHttpRequestAdapter).SendAsync(0xc0000c4230, {0x1, 0x0, 0xc000095320, 0xc000095350, {0xc0000bc180, 0x17, 0x18}, 0xc000095290, {0x70b29c, ...}, ...}, ...)
	/home/anramase/go/pkg/mod/github.com/microsoft/kiota/http/go/nethttp@v0.0.0-20211108132630-7da008c70103/nethttp_request_adapter.go:170 +0x158
github.com/microsoftgraph/msgraph-sdk-go/applications.(*ApplicationsRequestBuilder).Post(0xc0000952f0, 0x768ec8)
	/home/anramase/go/pkg/mod/github.com/microsoftgraph/msgraph-sdk-go@v0.1.1/applications/applications_request_builder.go:166 +0xc2
github.com/aramase/graphsdk/pkg/cloud.GraphClient({0x703c75, 0x300000002}, {0x703ac5, 0xc000032738}, {0x702bee, 0xc0000001a0})
	/home/anramase/go/src/github.com/aramase/graphsdkpkg/cloud/graphsdk.go:33 +0x208
main.main()
	/home/anramase/go/src/github.com/aramase/graphsdk/cmd/sample/main.go:20 +0x55

@baywet
Copy link
Member

baywet commented Nov 10, 2021

please make sure you update github.com/microsoft/kiota/serialization/go/json

@aramase
Copy link
Author

aramase commented Nov 10, 2021

please make sure you update github.com/microsoft/kiota/serialization/go/json

Thanks, that worked! github.com/microsoft/kiota/serialization/go/json is an indirect dependencies so missed updating that.

@baywet
Copy link
Member

baywet commented Nov 10, 2021

no worries, I know our dependency story is a bit messy at the moment, our plan is to get

  • github.com/microsoft/kiota/serialization/go/json
  • github.com/microsoft/kiota/authentication/go/azure
  • github.com/microsoft/kiota/http/go/nethttp
  • github.com/microsoft/kiota/abstractions/go

onto their own repo so the versioning can be better handled. But we're holding on that for now so we can move faster and on a common front with changes that both impact these libs and the generation process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants