Skip to content

innererror not deserialized in some ODataErrors #334

Closed

Description

Follow up from #218 (reply in thread).

It seems like we'd expect the innererror to be populated but it is not. instead, the innerError is stuffed into additionalData

minimal repro:

output:

(*odataerrors.ODataError)(0x140005b8240)(error status code received from the API)
 map[] (abstractions.ApiError) error status code received from the API
 (*odataerrors.MainError)(0x1400014e3c0)({
 additionalData: (map[string]interface {}) (len=1) {
  (string) (len=10) "innerError": (map[string]*jsonserialization.JsonParseNode) (len=3) {
   (string) (len=4) "date": (*jsonserialization.JsonParseNode)(0x14000112250)({
    value: (*string)(0x14000112240)((len=19) "...")
   }),
   (string) (len=10) "request-id": (*jsonserialization.JsonParseNode)(0x140001122b0)({
    value: (*string)(0x140001122a0)((len=36) "...")
   }),
   (string) (len=17) "client-request-id": (*jsonserialization.JsonParseNode)(0x14000112310)({
    value: (*string)(0x14000112300)((len=36) "...")
   })
  }
 },
 code: (*string)(0x14000112160)((len=18) "Request_BadRequest"),
 details: ([]odataerrors.ErrorDetailsable) <nil>,
 innererror: (odataerrors.InnerErrorable) <nil>,
 message: (*string)(0x140001121c0)((len=99) "One or more added object references already exist for the following modified properties: 'members'."),
 target: (*string)(<nil>)
})

Here's a minimal repro that attempts to add a user to a group they already exist in (must set that up before running):

package main

import (
	"context"
	"fmt"
	"log"

	azidentity "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/davecgh/go-spew/spew"
	a "github.com/microsoft/kiota-authentication-azure-go"
	msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
	"github.com/microsoftgraph/msgraph-sdk-go/models"
	"github.com/microsoftgraph/msgraph-sdk-go/models/odataerrors"
)

func main() {
	ctx := context.Background()
	cred, err := azidentity.NewClientSecretCredential("...", "...", "...", nil)
	if err != nil {
		panic(err)
	}

	auth, err := a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{})
	if err != nil {
		panic(err)
	}

	adapter, err := msgraphsdk.NewGraphRequestAdapter(auth)
	if err != nil {
		panic(err)
	}

	client := msgraphsdk.NewGraphServiceClient(adapter)

	req := models.NewReferenceCreate()
	id := fmt.Sprintf(
		"https://graph.microsoft.com/v1.0/directoryObjects/%s",
		"some-user-id-that-is-already-in-the-group",
	)
	req.SetOdataId(&id)
	if err := client.GroupsById("some-group-id").Members().Ref().Post(ctx, req, nil); err != nil {
		if odataErr, ok := err.(*odataerrors.ODataError); ok {
			log.Println("error", spew.Sdump(odataErr))
		}
		panic(err)
	}

	panic("expected panic above")
}

Activity

  1. baywet commented on Dec 8, 2022

    @baywet
    Member

    Thanks for reporting this Stephen Wan (@stephenwan-opal) !
    Ronald K (@rkodev) I believe this might be a casing issue during the deserialization, would you mind having a look at it please?

  2. rkodev commented on Dec 16, 2022

    @rkodev
    Contributor

    Vincent Biret (@baywet) this is the case for the given issue, the returned error from the api is innererror as opposed to innerError

  3. baywet commented on Dec 16, 2022

    @baywet
    Member

    Thanks for looking into this. Does this seem to be the case for a single API or is it happening for the whole apps surface area?

  4. baywet commented on Jan 4, 2023

    @baywet
    Member

    this is most likely related to #313

  5. baywet commented on Jan 24, 2023

    @baywet
    Member

    closing as consolidated with #313 to help with planning on our side.

    Stephen Wan (@stephenwan-opal) I suggest you to follow things over there to get notified of progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions