You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Each time the unleash client sends its metrics we see the error: "The appName property is required. It was not present on the data you sent." This is due to fact that the body is empty in the Post request call of the client/metrics call.
To Reproduce
Steps to reproduce the behavior:
Configure unleash with appName, projectId, apiKey, url, we use the System.Text.Json.JsonSerializer
Create an Unleashclient with FetchToggleInterval set to i.e. 20 seconds.
Call the client.IsEnabled("any flag", context)
Wait for next fetch interval
See error
Expected behavior
We should see no errors.
Actual behavior
We see the error: The appName property is required. It was not present on the data you sent. on each sendMetrics interval.
Desktop (please complete the following information):
OS: Windows
Browser chrome
Version 4.1.5 (latest at the moment of writing)
Additional context
After some debugging I see that the seek position of the memoryStream that is used to fill the appName, InstanceId, Bucket is not reset to the start of the stream. So when you pass it to the request.Content it will start reading at the end of the stream, so the body is always empty.
If you add the following line before passing the stream into the request.Content you will jump to the start of the stream and so your request body will contain the expected info.
memoryStream.Seek(0, SeekOrigin.Begin);
So this is an easy fix.
So in the file UnleashApiClient.cs in function SendMetrics: add this seek function as shown below:
...
using (metrics.StopCollectingMetrics(out var bucket))
{
jsonSerializer.Serialize(memoryStream, new ClientMetrics
{
AppName = clientRequestHeaders.AppName,
InstanceId = clientRequestHeaders.InstanceTag,
Bucket = bucket
});
}
memoryStream.Seek(0, SeekOrigin.Begin); //<=== HERE
The text was updated successfully, but these errors were encountered:
Describe the bug
Each time the unleash client sends its metrics we see the error: "The
appName
property is required. It was not present on the data you sent." This is due to fact that the body is empty in the Post request call of the client/metrics call.To Reproduce
Steps to reproduce the behavior:
Expected behavior
We should see no errors.
Actual behavior
We see the error: The
appName
property is required. It was not present on the data you sent. on each sendMetrics interval.Desktop (please complete the following information):
Additional context
After some debugging I see that the seek position of the memoryStream that is used to fill the appName, InstanceId, Bucket is not reset to the start of the stream. So when you pass it to the request.Content it will start reading at the end of the stream, so the body is always empty.
If you add the following line before passing the stream into the request.Content you will jump to the start of the stream and so your request body will contain the expected info.
memoryStream.Seek(0, SeekOrigin.Begin);
So this is an easy fix.
So in the file UnleashApiClient.cs in function SendMetrics: add this seek function as shown below:
The text was updated successfully, but these errors were encountered: