Azure / Azure/azure-rest-api-specs-examples

[Sample Issue dotnet] TablesListByWorkspace encounters System.InvalidOperationException

Open
#3,928 0 comments 0 reactions 1 assignee Claimed by @ArcturusZhang View on GitHub
customer-reported question
Dominant language
No language data
Stars
40
Forks
23
Avg merge
23h 36m
Merged PRs (30d)
172

Description

### Link to sample

https://learn.microsoft.com/en-us/rest/api/loganalytics/tables/list-by-workspace?view=rest-loganalytics-2022-10-01&tabs=dotnet

### Library name and version

Azure.ResourceManager.OperationalInsights 1.2.0

### Language of the Sample

- [X] C#/.NET
- [ ] Java
- [ ] JavaScript/TypedScript
- [ ] Python
- [ ] Golang
- [ ] Other - Please specify in Issue details field

### Sample Issue Type

- [X] Sample not working
- [ ] Sample missing
- [ ] Do not understand sample

### Issue details

When running the sample, I receive the following exception when calling collection.GetAllAsync():

System.InvalidOperationException: 'The requested operation requires an element of type 'String', but the target element has type 'True'.'

It seems to happen here:

```
// File: Models\OperationalInsightsTableData.Serialization.cs

if (property0.NameEquals("retentionInDaysAsDefault"u8))
{
if (property0.Value.ValueKind == JsonValueKind.Null)
{
property0.ThrowNonNullablePropertyIsNull();
continue;
}
// Exception thrown here
retentionInDaysAsDefault = new RetentionInDaysAsDefaultState(property0.Value.GetString());
continue;
}
```

If I try to do the following:

```
// This table exists. Same exception.
var table = collection.Get("AACAudit");

// This table does not exist. No exception thrown.
var table = collection.Get("madeuptable");
```

### Expected behavior

I would expect the call to successfully complete without throwing an exception.

### Actual behavior

The call always throws an exception even when using different log analytic workspaces that I have access to.

### Reproduction Steps

Run the sample with a valid subscriptionId, resourceGroupId, and workspace name.

### Environment

.NET SDK:
Version: 7.0.306
Commit: f500069cb7

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64

Host:
Version: 7.0.14
Architecture: x64
Commit: 808851b07a

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.