Skip to content

[BUG] Multivariant results containing an error causing parse issue #36781

Open

Description

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

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

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Cognitive - Anomaly DetectorService AttentionWorkflow: This issue is responsible by Azure service team.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions