Azure/azure-iot-sdk-csharp

[Bug Report] Querying jobs from some IoT Hubs returns an unexpected ArgumentException

matthewshan opened this issue · 5 comments

Context

  • OS, version, SKU and CPU architecture used: Windows 10 Enterprise | Intel(R) Core(TM) i7-10750H (I am also observing this issue on an Azure Function app running on windows)
  • Application's .NET Target Framework : net6.0
  • Device: Laptop
  • SDK version used: 1.39.0 (Please include the NuGet package version for all involved components)

Description of the issue

When attempting to query a list of jobs from one of our IoT Hubs, I get "Requested value 'unknown' was not found." I see this error for some IoT Hubs, whereas others do not. After hours of debugging, I cannot identify the differentiating factors. One s1 iot hub allows for this code, and a different s1 and one free tier iot hub produces this error.

I double-checked to see that all my jobs have the status of completed and the type of scheduleUpdateTwin on all of these hubs

Code sample exhibiting the issue

public async Task<List<JobResponse>> GetActiveJobs(string connectionString)
    {
        var jobClient = JobClient.CreateFromConnectionString(connectionString);
        var query = jobClient.CreateQuery(jobType: JobType.ScheduleUpdateTwin, jobStatus: JobStatus.Running);

        var activeJobs = new List<JobResponse>();
        while (query.HasMoreResults)
        {
            var result = await query.GetNextAsJobResponseAsync(); // <-- Error is thrown on this line
            if (result != null)
            {
                activeJobs.AddRange(result);
            }
        }

        await jobClient.CloseAsync();

        return activeJobs;
    }

Console log of the issue

System.ArgumentException: Requested value 'unknown' was not found.
   at System.Enum.TryParseByName(RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, UInt64& result)
   at System.Enum.TryParseInt32Enum(RuntimeType enumType, ReadOnlySpan`1 value, Int32 minInclusive, Int32 maxInclusive, Boolean ignoreCase, Boolean throwOnFailure, TypeCode type, Int32& result)
   at System.Enum.TryParse(Type enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, Object& result)
   at System.Enum.Parse(Type enumType, String value)
   at Microsoft.Azure.Devices.QueryResult.FromHttpResponseAsync(HttpResponseMessage response)
   at Microsoft.Azure.Devices.JobClient.GetJobsAsync(Nullable`1 jobType, Nullable`1 jobStatus, Nullable`1 pageSize, String continuationToken, CancellationToken cancellationToken)
   at Microsoft.Azure.Devices.Query.GetNextAsync(QueryOptions options)
   at Microsoft.Azure.Devices.Query.GetAndCastNextResultAsync[T](QueryResultType type, QueryOptions options)
   at Microsoft.Azure.Devices.Query.GetNextAsJobResponseAsync(QueryOptions options)
   at Microsoft.Azure.Devices.Query.GetNextAsJobResponseAsync()
   at TestProject.Libraries.IotJobsHelper.GetJobs(String connectionString) in IotJobsHelper.cs:line 40
   at Program.<Main>$(String[] args) in Program.cs:line 8

Tasks

Preview Give feedback
No tasks being tracked yet.

Bump

The service side of this has changed lately, and it's possible that this bug is because of that. I'll follow up with the service engineers to see if something was broken here.

Service side engineers have confirmed that this is a bug that they are working to fix. You should get this fix as soon as the service team deploys it. Since this isn't an SDK-side bug, I'll go ahead and close this thread.

@timtay-microsoft Thanks for the update! I'm unfortunately still seeing this as an issue. Is there a ticket on their end we can use to track this issue, or any news feeds I should pay attention to?

If you open a ticket through the Azure portal, you should be able to getter a better picture of when the service team will have this fix rolled out to your hub. We don't really track service-side updates in this or any other SDK repo, unfortunately.