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

unsupported AdditionalData type: map[string]*jsonserialization.JsonParseNode Write Object #24

Closed
dadams39 opened this issue Jun 7, 2022 · 7 comments · Fixed by #26
Closed
Assignees
Labels
bug Something isn't working fixed

Comments

@dadams39
Copy link
Contributor

dadams39 commented Jun 7, 2022

Version 0.4
Used with msgraph-sdk-go current versionv0.25.0
In the following sequence:

err = objectWriter.WriteObjectValue("", message)
			if err != nil {
				fmt.Printf("Error %d %v\n", err)
				fmt.Println(string(message))
			}

This is the message that is printed out. At first inspection, all of the data appears to be valid (e.g. comma separated)

{"id":"AAMkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwBGAAAAAADCNgjhM9QmQYWNcI7hCpPrBwDSEBNbUIB9RL6ePDeF3FIYAAAAAAEMAADSEBNbUIB9RL6ePDeF3FIYAAAfMZjxAAA=","@odata.etag":"W/\"CQAAABYAAADSEBNbUIB9RL6ePDeF3FIYAAAfMbDG\"","categories":[],"changeKey":"CQAAABYAAADSEBNbUIB9RL6ePDeF3FIYAAAfMbDG","createdDateTime":"2022-05-18T20:58:43Z","lastModifiedDateTime":"2022-05-18T20:58:47Z","bccRecipients":[],"body":{"content":"<html><head>^M
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\" style=\"display:none\">^M
<!--^M
p^M
        {margin-top:0;^M
        margin-bottom:0}^M
-->^M
</style></head><body dir=\"ltr\"><div class=\"elementToProof\" style=\"font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)\">Test 4</div></body></html>","contentType":"html"},"bodyPreview":"Test 4","ccRecipients":[],"conversationId":"AAQkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwAQALOAc1dB-HdMpyprK_YCfKw=","conversationIndex":"AQHYavoMs4BzV0H8d0ynKmsr5gJ8rA==","flag":{"flagStatus":"notFlagged"},"from":{"emailAddress":{"address":"[email protected]","name":"George"}},"hasAttachments":false,"importance":"normal","inferenceClassification":"focused","internetMessageId":"<DM6PR17MB4010DEDD6381E73CA36A22C6F6D19@DM6PR17MB4010.namprd17.prod.outlook.com>","isDraft":false,"isRead":false,"isReadReceiptRequested":false,"parentFolderId":"AAMkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwAuAAAAAADCNgjhM9QmQYWNcI7hCpPrAQDSEBNbUIB9RL6ePDeF3FIYAAAAAAEMAAA=","receivedDateTime":"2022-05-18T20:58:43Z","replyTo":[],"sender":{"emailAddress":{"address":"[email protected]","name":"George"}},"sentDateTime":"2022-05-18T20:58:38Z","subject":"Test 4","toRecipients":[{"emailAddress":{"address":"[email protected]","name":"Mark 8 Project Team"}}],"webLink":"https://outlook.office365.com/owa/?ItemID=AAMkAGZmNjNlYjI3LWJlZWYtNGI4Mi04YjMyLTIxYThkNGQ4NmY1MwBGAAAAAADCNgjhM9QmQYWNcI7hCpPrBwDSEBNbUIB9RL6ePDeF3FIYAAAAAAEMAADSEBNbUIB9RL6ePDeF3FIYAAAfMZjxAAA%3D&exvsurl=1&viewmodel=ReadMessageItem"}

Change to only the email address and display name.

@dadams39
Copy link
Contributor Author

dadams39 commented Jun 8, 2022

When trying to recreate the object with the same data (investigating the error), receive:
Error failed: invalid character '\n' in string literal
When performing the operation:

anObject, err := NewJsonParseNodeFactory().GetRootParseNode("application/json", object)
if err != nil{
     // See error above
}

@dadams39
Copy link
Contributor Author

dadams39 commented Jun 8, 2022

Running the code in Jsonlint, the code appears to be have created in an invalid manner

Error: Parse error on line 10:
...dy": {		"content": "<html><head>^M <		
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'

@baywet, I'm going to keep looking into this; however, I'm not seeing a correlation with the Additional Data that could be causing only a subset of messages to be corrupted.

@dadams39
Copy link
Contributor Author

dadams39 commented Jun 9, 2022

Quoted from most recent changeLog.md

Changed
Updated supported types for Additional Data, unsupported types now throwing an error instead of ignoring.

The curious question is how to rectify? If an unchanged object is serialized and throws an error, it feels like there should be a more specific ticket to enhance the abstraction.

@baywet
Copy link
Member

baywet commented Jun 9, 2022

Thanks for your patience on the delayed reply.
From the information you provided I believe the new lines characters in the content string not being escaped is what produced invalid JSON.
I just put together #26 to address this issue, let me know if you need anything else.

@baywet baywet self-assigned this Jun 9, 2022
@baywet baywet added bug Something isn't working fixed labels Jun 9, 2022
@dadams39
Copy link
Contributor Author

Going to reopen the additional data... I'm seeing the same failure on multiple types of mail. Two different additional data headers are included below:

Number 1:

map[string]interface {} ["@odata.type": *"#microsoft.graph.eventMessageResponse", "isDelegated": *false, 
"endDateTime": map[string]*github.com/microsoft/kiota-serialization-json-go.JsonParseNode ["dateTime": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002a5460), "timeZone": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002a54e0), ], 
"type": *"singleInstance", "responseType": *"accepted", "@odata.etag": *"W/\"DAAAABYAAAB8wYc0thTTTYl3RpEYIUq+AAAfar4a\"", "isOutOfDate": *false, "isAllDay": *false,
 "meetingMessageType": *"meetingAccepted",
 "startDateTime": map[string]*github.com/microsoft/kiota-serialization-json-go.JsonParseNode ["dateTime": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002a5330), "timeZone": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002a53c0), ], ]

Number 2:

map[string]interface {} ["type": *"singleInstance", "isDelegated": *false, "location": map[string]*github.com/microsoft/kiota-serialization-json-go.JsonParseNode ["displayName": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002e5720), "locationType": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002e5780), "uniqueIdType": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002e57e0), ], "startDateTime": map[string]*github.com/microsoft/kiota-serialization-json-go.JsonParseNode ["dateTime": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002e5540), "timeZone": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002e55a0), ], "endDateTime": map[string]*github.com/microsoft/kiota-serialization-json-go.JsonParseNode ["dateTime": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002e5630), "timeZone": *(*"github.com/microsoft/kiota-serialization-json-go.JsonParseNode")(0x140002e5690), ], "meetingMessageType": *"meetingRequest", "meetingRequestType": *"newMeetingRequest", "@odata.type": *"#microsoft.graph.eventMessageRequest", "@odata.etag": *"W/\"CwAAABYAAADSEBNbUIB9RL6ePDeF3FIYAAAAAAsl\"", "isOutOfDate": *false, "responseRequested": *true, "isAllDay": *false, ]

@dadams39
Copy link
Contributor Author

@baywet Can we reopen this issue or do we have to create a new one?

@baywet
Copy link
Member

baywet commented Jun 21, 2022

Please open a new one, I think this is different.

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
2 participants