Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDK Binding - Blob] Improve error logging when deserialization fails for POCO scenarios #1329

Closed
liliankasem opened this issue Feb 9, 2023 · 3 comments

Comments

@liliankasem
Copy link
Member

If you bind to a POCO i.e.

[BlobInput("book-container", IsBatched = true)] Book[] books)

The format of the blob needs to be json, for example:

book.json -> { "id": "1", "name": "mybook" }

If you don't do that and use a blob with string content, the deserialization will fail with an error that looks like this:

Executed 'Functions.BlobInputBookArrayFunction' (Failed, Id=501b3023-ee56-41f4-a99d-332bba664544, Duration=66ms)

[2023-02-09T21:45:01.210Z] System.Private.CoreLib: Exception while executing function: Functions.BlobInputBookArrayFunction. System.Private.CoreLib: Result: Failure

[2023-02-09T21:45:01.210Z] Exception: Microsoft.Azure.Functions.Worker.FunctionInputConverterException: Error converting 1 input parameters for Function 'BlobInputBookArrayFunction': Cannot convert input parameter 'books' to type 'SampleApp.Book[]' from type 

'Microsoft.Azure.Functions.Worker.Grpc.Messages.GrpcCollectionModelBindingData'. Error:System.Text.Json.JsonException: 'h' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.

We should consider improving the logging here. This exception is currently caught in our try-catch so this would be a good place to display a better error message:

var element = await ConvertModelBindingDataAsync(content, elementType, modelBindingData);
if (element is not null)
{
blobCollection.Add(element);
}
}
var methodName = context.TargetType.IsArray ? nameof(CloneToArray) : nameof(CloneToList);
var result = ToTargetTypeCollection(blobCollection, methodName, elementType);
return ConversionResult.Success(result);
}
catch (Exception ex)
{
return ConversionResult.Failed(ex);
}

@fabiocav
Copy link
Member

Flagging to investigate what, if any, enhancements we can make to this.

@liliankasem liliankasem changed the title Improve error logging when deserialization fails for POCO scenarios Improve error logging when deserialization fails for POCO scenarios (blob converter) Feb 16, 2023
@liliankasem liliankasem changed the title Improve error logging when deserialization fails for POCO scenarios (blob converter) [Blob Converter] Improve error logging when deserialization fails for POCO scenarios Feb 16, 2023
@liliankasem liliankasem changed the title [Blob Converter] Improve error logging when deserialization fails for POCO scenarios [SDK Binding - Blob] Improve error logging when deserialization fails for POCO scenarios Feb 17, 2023
@fabiocav
Copy link
Member

fabiocav commented Jun 8, 2023

Assigning to sprint 148 for validation

@aishwaryabh
Copy link
Contributor

This error still repros, so I'll create a fix for displaying a better display message.

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

No branches or pull requests

4 participants