-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[BUG] Fatal parse error analysing document using invoice model - "not recognized as a valid DateTime" #27137
Comments
Thank you for your feedback. Tagging and routing to the team member best able to assist. |
Hello @kweebtronic. Thank you for bringing this matter to our attention. This issue has been reported by other customers in the past, and we are currently considering the possibility of adding For the time being, have you tried accessing the |
To access DocumentField.Content I need to navigate sub-properties of the response class (response.Value.Documents[].Fields[]) Am I supposed to write some sort of try-catch logic for resolving the API response classes? Still fails:
|
@kweebtronic Now I see I misunderstood the issue, so please disregard my previous reply. The behavior you're describing seems to be a bug. From my understanding, the service is returning a document field with |
@kinelski yes, traced the HTTP response and yes for some reason the API has returned that as a date value. Extract of detected invoice item (from HTTP trace of SDK call to API - request still failed to return value to my class):
|
@kweebtronic Apologies for the delayed response. I have discussed this matter with the service team and confirmed it's a bug. They already have a fix but deployment is expected to take around two weeks, so I'll get back to you when that happens. Once the fix is in place, you won't be able to access the field date value with If you're blocked by this bug and need a fix asap, you could use an HTTP policy to intercept the service response and manually remove the dates causing the bug: internal class DateFixPolicy : HttpPipelineSynchronousPolicy
{
public override void OnReceivedResponse(HttpMessage message)
{
if (message.Response.ContentStream != null)
{
byte[] bytes = message.Response.Content.ToArray();
string content = Encoding.UTF8.GetString(bytes);
string modifiedContent = Regex.Replace(content, "\"valueDate\":\"yyyy-[0-9]{2}-[0-9]{2}\"", "\"valueDate\":null");
message.Response.ContentStream.Dispose();
message.Response.ContentStream = new MemoryStream(Encoding.UTF8.GetBytes(modifiedContent));
}
base.OnReceivedResponse(message);
}
} You need to set it in the client options like this: var options = new DocumentAnalysisClientOptions();
options.AddPolicy(new DateFixPolicy(), HttpPipelinePosition.PerCall);
var client = new DocumentAnalysisClient(<endpoint>, <credential>, options); |
@kweebtronic The fix has been deployed. Could you confirm if you can still repro the bug? |
Thanks @kinelski , I am now able to retrieve the document analysis value with the SDK, without error |
That's great! Feel free to open another issue if you have any other issues. |
Library name and version
Azure.AI.FormRecognizer 4.0.0-beta.3
Describe the bug
Send a document to the analyser for 'invoice' processing.
Service responds without error but SDK throws exception due to parsing issue.
Expected behavior
SDK should return the analysed document information, with best efforts at recognising data types
This should be a TRY parse, not fail everything because of one dubious value.
Analysis model should be flexible enough to return values just as text, if they are 'date-ish' or 'number-ish'
Actual behavior
SDK throws System.FormatException:
Reproduction Steps
Submitting financial document so won't provide the source data, but the stack trace should be sufficient to trace the root cause... this is a vanilla call to the client
Environment
.NET SDK (reflecting any global.json):
Version: 6.0.200
Commit: 4c30de7899
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.200\
Host (useful for support):
Version: 6.0.2
Commit: 839cdfb0ec
The text was updated successfully, but these errors were encountered: