Skip to content

Backport #9430: [28.x] E-Document ADI import crashes with untrappable JSON error when ADI response lacks outputs.1 structure - #9901

Open
ventselartur wants to merge 1 commit into
releases/28.xfrom
backport/releases/28.x/644118
Open

Backport #9430: [28.x] E-Document ADI import crashes with untrappable JSON error when ADI response lacks outputs.1 structure#9901
ventselartur wants to merge 1 commit into
releases/28.xfrom
backport/releases/28.x/644118

Conversation

@ventselartur

@ventselartur ventselartur commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Backport of #9430 for AB#644118

## 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.


[AB#640122](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/640122)

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ventselartur
ventselartur requested review from a team August 3, 2026 10:51
@ventselartur
ventselartur requested a review from a team as a code owner August 3, 2026 10:51
@github-actions github-actions Bot added AL: Apps (W1) Add-on apps for W1 Team: Integrations GitHub request for Integrations area labels Aug 3, 2026
@github-actions github-actions Bot added this to the Version 28.5 milestone Aug 3, 2026
@alexei-dobriansky

Copy link
Copy Markdown
Contributor

Good Sense Reviewer - Round 1

Recommendation: Request Changes
Problem-solution fit: Partial

This is a faithful code port of #9430 into 28.x, and it does prevent the missing-key crash. But it still leaves the malformed-shape case open, so the stated ADI crash fix is not complete.

Suggestions

  • S1 (🔴 High) Wrong JSON token types still crash the helper - The new checks only handle missing keys. GetInnerObject() and GetHeaderFields() still call AsObject() without JsonToken.IsObject(), so payloads like outputs: [] or fields: "x" can still raise the same untrappable runtime error. Treat wrong token types the same as missing properties, or reuse a helper that validates both presence and shape.

Risk & necessity

This backport is worth taking because the current 28.x code can crash on malformed ADI responses in a user-facing import path. If it ships as-is, some malformed responses will still crash instead of degrading gracefully, so the risk is reduced but not removed.


[AI-PR-REVIEW] version=1 promptVersion=4 system=github pr=9901 round=1 by=alexei-dobriansky at=2026-08-26T22:29:55Z lastSha=716bb4ee5fcca206f57a7958b19e72192817cb2f reviewKey=74c586ec096b03026908d3c4b408e97a9492c23bcf287a018e052aedbc1ea94a suggestions=S1@7a1c2e4f

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 Team: Integrations GitHub request for Integrations area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants