Skip to content

Fix untrappable JSON error in E-Document ADI import (Bug 640122)#9430

Open
ventselartur wants to merge 3 commits into
mainfrom
bugs/640122-EDocADICrashes
Open

Fix untrappable JSON error in E-Document ADI import (Bug 640122)#9430
ventselartur wants to merge 3 commits into
mainfrom
bugs/640122-EDocADICrashes

Conversation

@ventselartur

@ventselartur ventselartur commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Why

The E-Document Matching Assistance (ADI) import path in EDocument Json Helper read properties from the ADI response using JsonObject.Get(...) without checking the boolean return value. When the Azure Document Intelligence response was malformed or missing an expected property (outputs, 1, result, or fields), the subsequent JsonToken.AsObject() call operated on an uninitialized token, raising an untrappable runtime error that crashed the import instead of degrading gracefully.

Summary

  • Fixed the untrappable JSON error by guarding every Get call in GetInnerObject and GetHeaderFields; when an expected property is absent the helper now returns an empty JsonObject instead of dereferencing an uninitialized token.
  • Added telemetry (0000UK1-0000UK4, Warning) under the "E-Document Matching Assistance" category so malformed ADI responses are diagnosable, with a locked label naming the missing property.

ventselartur and others added 3 commits July 14, 2026 11:53
GetInnerObject and GetHeaderFields in codeunit 6121 "EDocument Json Helper"
discarded the Boolean result of JsonObject.Get, so the AL runtime used the
throwing overload and raised an untrappable NavNCLJsonPropertyNotFoundException
when an ADI AnalyzeInvoice response was non-empty but lacked the expected
outputs."1".result / fields shape.

Guard every lookup and return an empty JsonObject on any missing key, mirroring
GetLinesArray. A malformed ADI response now yields a blank draft instead of a
crash; downstream setters already no-op on empty objects.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 027b8c29-fadf-49a3-8e96-432cddb5e394
Log a Warning-verbosity telemetry event whenever GetInnerObject or
GetHeaderFields encounters a missing key in the ADI response and returns an
empty object. Uses a blank event tag to be filled by Expand-TelemetryTags.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 027b8c29-fadf-49a3-8e96-432cddb5e394
@ventselartur ventselartur requested review from a team July 14, 2026 12:47
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234'

@github-actions

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 1 · Outcome: completed

Knowledge source: https://github.com/microsoft/BCQuality@be1b92b624679f8c031061602e7d3a3b5f71a688

Findings by domain

Findings split into Knowledge-backed (cite a BCQuality article) and Agent (the agent's own judgement, no matching BCQuality rule).

Domain Findings Knowledge-backed Agent Inline Fallback
Other 15 15 0 0 0
Style 1 0 1 0 0

Totals: 15 knowledge-backed · 1 agent findings.

Orchestrator pre-filter (16 file(s) excluded)

  • layer-disabled (knowledge) : 16 file(s)

Findings produced by the Copilot CLI agent against BCQuality at be1b92b624679f8c031061602e7d3a3b5f71a688. Reply 👎 on any inline comment to flag false positives.

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

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants