Description
openedon Jun 1, 2023
Library name and version
Azure.AI.AnomalyDetector 3.0.0-preview.7
Describe the bug
Trained a Multivariant model, now testing batch detection causing on this line
MultivariateDetectionResult response = client.GetMultivariateBatchDetectionResult(resultId);
the following exception:
Unhandled exception. System.InvalidOperationException: The requested operation requires an element of type 'Boolean', but the target element has type 'Null'.
at System.Text.Json.JsonElement.<GetBoolean>g__ThrowJsonElementWrongTypeException|17_0(JsonTokenType actualType)
at System.Text.Json.JsonElement.GetBoolean()
at Azure.AI.AnomalyDetector.AnomalyValue.DeserializeAnomalyValue(JsonElement element)
at Azure.AI.AnomalyDetector.AnomalyState.DeserializeAnomalyState(JsonElement element)
at Azure.AI.AnomalyDetector.MultivariateDetectionResult.DeserializeMultivariateDetectionResult(JsonElement element)
at Azure.AI.AnomalyDetector.MultivariateDetectionResult.FromResponse(Response response)
at Azure.AI.AnomalyDetector.AnomalyDetectorClient.GetMultivariateBatchDetectionResult(String resultId, CancellationToken cancellationToken)
...
While debugging this I found this result entry causing the issue since isAnomaly is not checked for null values in the code parsing it:
{
"timestamp": "2023-05-27T10:00:00Z",
"value": {
"isAnomaly": null,
"severity": null,
"score": null,
"interpretation": null
},
"errors": [
{
"code": "InsufficientHistoricalData",
"message": "Inference data is not enough. Please make sure the length of inference data is longer than one sliding window."
}
]
}
This may occur for other error message as well of course.
Expected behavior
To parse the result so the user can see the error message.
Actual behavior
Trained a Multivariant model, now testing batch detection causing on this line
MultivariateDetectionResult response = client.GetMultivariateBatchDetectionResult(resultId);
the following exception:
Unhandled exception. System.InvalidOperationException: The requested operation requires an element of type 'Boolean', but the target element has type 'Null'.
at System.Text.Json.JsonElement.<GetBoolean>g__ThrowJsonElementWrongTypeException|17_0(JsonTokenType actualType)
at System.Text.Json.JsonElement.GetBoolean()
at Azure.AI.AnomalyDetector.AnomalyValue.DeserializeAnomalyValue(JsonElement element)
at Azure.AI.AnomalyDetector.AnomalyState.DeserializeAnomalyState(JsonElement element)
at Azure.AI.AnomalyDetector.MultivariateDetectionResult.DeserializeMultivariateDetectionResult(JsonElement element)
at Azure.AI.AnomalyDetector.MultivariateDetectionResult.FromResponse(Response response)
at Azure.AI.AnomalyDetector.AnomalyDetectorClient.GetMultivariateBatchDetectionResult(String resultId, CancellationToken cancellationToken)
...
Reproduction Steps
Every time I trigger the batch detection and causing a result like the following the error above is happening:
{
"timestamp": "2023-05-27T10:00:00Z",
"value": {
"isAnomaly": null,
"severity": null,
"score": null,
"interpretation": null
},
"errors": [
{
"code": "InsufficientHistoricalData",
"message": "Inference data is not enough. Please make sure the length of inference data is longer than one sliding window."
}
]
}
Environment
.NET SDK:
Version: 7.0.302
Commit: 990cf98a27
Runtime Environment:
OS Name: Mac OS X
OS Version: 13.4
OS Platform: Darwin
RID: osx.13-x64
Base Path: /usr/local/share/dotnet/sdk/7.0.302/
Host:
Version: 7.0.5
Architecture: x64
Commit: 8042d61b17
.NET SDKs installed:
6.0.406 [/usr/local/share/dotnet/sdk]
6.0.407 [/usr/local/share/dotnet/sdk]
6.0.408 [/usr/local/share/dotnet/sdk]
7.0.201 [/usr/local/share/dotnet/sdk]
7.0.202 [/usr/local/share/dotnet/sdk]
7.0.203 [/usr/local/share/dotnet/sdk]
7.0.302 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download