trackTrace model being manipulated to invalid
See original GitHub issueHello,
We have used AppInsights JS SDK for quite a while now (currently on v2.7.2). Recently we noticed in our logs we were not receiving everything we’re sending. Upon inspection it appears that sometimes when we use trackTrace
the simple object of message (string), properties (object), and severityLevel (number) is being malformed and is causing the request to come over as an object instead.
While this is not according to spec it also does not always complain about this. Sometimes the message as an object is allowed and other times a 400 error is thrown. I have checked all of our code and we are passing a string for the message and an object for properties to the AppInsights JS SDK. This means something in the SDK is somtimes malforming the message to be an object with a message and properties property in it. Below are some example requests that are sent to the SDK as well as what the SDK sends to the server and what the server sends back:
Example 1: Requests submitted to SDK:
{
message: "modules/a-module.connect() id=asdf-asdf-asdf-asdf",
properties: {
simulated: "false"
},
severityLevel: null
}
{
message: "modules/a-module.discoveryResult() devices(s)",
properties: [
0: {
label: "Device A",
status: "online"
},
1: {
label: "Device B",
status: "offline"
},
],
severityLevel: null
}
Request submitted to server from SDK (removing some properties for brevity):
[
0: {
data: {
baseData: {
message: "modules/a-module.connect() id=asdf-asdf-asdf-asdf",
properties: {
simulated: "false"
},
ver: 2
},
baseType: "MessageData"
}
},
1: {
data: {
baseData: {
message: {
message: "modules/a-module.discoveryResult() devices(s)",
properties: [
0: {
label: "Device A",
status: "online"
},
1: {
label: "Device B",
status: "offline"
},
],
severityLevel: null
},
properties: {},
ver: 2
},
baseType: "MessageData"
}
}
]
Note that in the above the first instance is correct (message is a string, properties is an object) and the server accepts it. In the second instance we have a malformed request now where message is now an object with properties message (string), properties (object), and severityLevel (number). The server still accepts this request and I can see both of these in the logs. Also to note is the first example does not have severityLevel in the SDK request but the second one does. In both instances our code sent a null for severityLevel.
Response from server:
{
errors: {},
itemsAccepted: 2,
itemsReceived: 2
}
Example 2: Requests submitted to SDK:
{
message: "modules/a-module.selectDevice()",
properties: {
label: "Device A",
status: "online"
},
severityLevel: null
}
Request submitted to server from SDK (removing some properties for brevity):
[
0: {
data: {
baseData: {
message: {
message: "modules/a-module.selectDevice()",
properties: [
0: {
label: "Device A",
status: "online"
}
],
severityLevel: null
},
properties: {},
ver: 2
},
baseType: "MessageData"
}
}
]
In the above in this example it’s the same as the second request in the first example in terms of structure where message is not a string as it should be but rather an object with properties of message (string), properties (object), and severityLevel (number). Unlike the first example though, this rejected by the server and we cannot see it in the logs.
Response from server:
{
errors: [{
0: {
index: 0,
message: "106: Field 'message' on type 'MessageData' is of incorrect type. Expected: string, Actual: [object Object]",
statusCode: 400
}
}],
itemsAccepted: 0,
itemsReceived: 1
}
There appears to be some issue within the SDK that is sometimes malforming the message to include other things like properties. This is causing the server to receive an object instead of a string. Additionally the server only sometimes rejects the malformed message object as bad. This is causing us to be partially blind into the actions the code is taking when there are issues. Our code only passes an object with properties message (string), properties (object), and severityLevel (number) to the trackTrace method. However for some reason sometimes the request the SDK sends to the server is correct and sometimes it is not. Likewise sometimes the server accepts the incorrect message object and other times rejects it.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (4 by maintainers)
Top GitHub Comments
Thanks for standing by. We’ve been in production with these changes for several days now and can confirm we are receiving all logging messages now vs before when it was only some. Removing the injected script from our views using the Nuget package was the issue causing the conflict.
This Issue will be closed in 30 days. Please remove the “Stale” label or comment to avoid closure with no action.