microsoft / Microsoft-Fabric-workload-development-sample

Demonstrates how to implement a Microsoft Fabric workload in .net and typescript
Other
30 stars 16 forks source link

Incorrect value type passed for invokeType in callback from Fabric #131

Closed asifkazi closed 2 weeks ago

asifkazi commented 1 month ago

Yes. When workloadClient.itemSchedule.runItemJob is called, the job is scheduled for processing and thus we see 202 returned.

Fabric asynchronously calls the Backend code , in particular, it should reach the method [CreateItemJobInstanceAsync]

It also queries the GetItemJobInstanceStateAsync method to get the status of the job.

The Backend call fails with a 422 error, because its expecting a string in the call back but in actuality the value is an integer

The documentation for this API says the invokeType is a String: [https://learn.microsoft.com/en-us/rest/api/fabric/workload/workloadapi/jobs/create-item-job-instance?tabs=HTTP#jobinvoketype]

However it's actually sending it as an integer, presumably the Enum value of the type:

{"invokeType":2,"creationPayload":{...}}
atefsaw commented 3 weeks ago

Hi @asifkazi , Can you please elaborate on what call you're referring to that sends this request: "{"invokeType":2,"creationPayload":{...}}"?

amos-osmos commented 3 weeks ago

Hi @asifkazi , Can you please elaborate on what call you're referring to that sends this request: "{"invokeType":2,"creationPayload":{...}}"?

Answering for Asif since he opened the issue on my behalf. This is when Fabric is calling our workload backend which is triggered by our frontend calling workloadClient.itemSchedule.runItemJob. We are not using C# for our backend, so this is a REST call being made which we then have to deserialize ourselves.

https://learn.microsoft.com/en-us/rest/api/fabric/workload/workloadapi/jobs/create-item-job-instance

Note: Just suffered the same problem with this: https://learn.microsoft.com/en-us/rest/api/fabric/workload/workloadapi/endpoint-resolution/resolve?source=docs#endpointresolutioncontextpropertyname The only thing I can see is instead of getting "TenantId" we're getting 3 (see below):

{
  "context": [
    {
      "name": 3,
      "value": "<Tenant's GUID>"
    }
  ]
}

The docs leads me to believe we'd get:

{
  "context": [
    {
      "name": "TenantId",
      "value": "<Tenant's GUID>"
    }
  ]
}
atefsaw commented 3 weeks ago

@amos-osmos ,

Thank you for bringing this to our attention. We've reviewed the behavior and confirmed that our current request implementation does not align with the API documentation, where the type of these fields should be a string instead of an integer value that represent the enum.

We will work on a fix to resolve this. In the meantime, we recommend adding a converter that maps the request field type from integer values to strings, similar to the approach we use in our C# boilerplate sample. This converter can also be configured to accept both integers and strings, ensuring compatibility with future updates.

Please let me know if you need further assistance.

kiratp commented 3 weeks ago

@atefsaw can you please share the enum on your end being used?

The ordering in the docs doesn't line up 3 with "TenantId"

https://learn.microsoft.com/en-us/rest/api/fabric/workload/workloadapi/endpoint-resolution/resolve?source=docs#endpointresolutioncontextpropertyname

atefsaw commented 2 weeks ago

Hello Kirat, the enum representation of these numerical zero-based values, in order, is: "EndpointName", "TenantRegion", "WorkspaceRegion", "TenantId".