Fix AI Eval Log Entries crash on Input/Output display (AB#621544)#8506
Fix AI Eval Log Entries crash on Input/Output display (AB#621544)#8506Groenbech96 wants to merge 2 commits into
Conversation
The AI Eval Log Entries page crashes when the user clicks Input or Output to view the captured content. Root cause: SetInputBlob/GetInputBlob and SetOutputBlob/GetOutputBlob in AITLogEntry.Table.al use binary Write()/Read() on the BLOB OutStream/InStream. Binary Write(Text) prepends length metadata; Read(var Text) then reads until a 0 byte and errors when the requested length and available length differ. Calling GetXxxBlob() from the AI Test Data Compare page therefore raises a runtime error and the page fails to open. Fix: switch the four affected calls to WriteText/ReadText, matching the pattern already used by the sibling GetMessage/GetErrorCallStack procedures in the same table. Tests: add codeunit "AIT Log Entry Blob Test" (149060) with seven roundtrip tests for SetXxxBlob/GetXxxBlob. Each test persists the record via Insert(false) and reloads it via Get() so the CalcFields-based read path used by the page is exercised. The tests fail against the binary Write/Read code and pass against the WriteText/ReadText fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d47fffe to
8d05fd2
Compare
Avoids O(n^2) string concatenation flagged in PR review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Thanks for the review. Triage:
|
What & why
The AI Eval Log Entries page crashes when the user clicks Input or Output to view the captured content for an entry. The crash happens before any content is displayed, so test results cannot be inspected from the page.
Root cause
SetInputBlob/GetInputBlobandSetOutputBlob/GetOutputBlobinAITLogEntry.Table.aluse the binaryOutStream.Write(Text)/InStream.Read(var Text)overloads on the BLOB stream.OutStream.Write(Text)prepends length metadata to the stream (and ends with a0byte for the text overload).InStream.Read(var Text)reads until a0byte or the requested length; when the requested and available lengths differ it raises a runtime error.When the AI Test Data Compare page calls
GetInputBlob/GetOutputBlobto display the saved content, the mismatched read length raises that error and the page fails to open.Fix
Switch the four affected calls in
AITLogEntry.Table.alfromWrite/ReadtoWriteText/ReadText, matching the pattern already used by the siblingGetMessage/GetErrorCallStackprocedures in the same table.Linked work
Fixes AB#621544
How I validated this
What I tested and the outcome
Added a new test project AI Test Toolkit Tests (
build/projects/AI Test Toolkit Tests/) following the same shape as Performance Toolkit Tests, with a new appsrc/Tools/AI Test Toolkit/Test/. The app contains codeunit149060 "AIT Log Entry Blob Test"with seven tests for the Input/Output BLOB roundtrip:InputBlobRoundtripSimpleTextOutputBlobRoundtripSimpleTextInputBlobRoundtripEmptyTextInputBlobRoundtripMultilineTextInputBlobRoundtripUnicodeTextInputBlobRoundtripJsonPayload(mirrors the AI Test Data Compare payload shape that triggers the page crash)InputBlobRoundtripLargeTextEach test persists the record via
Insert(false)and reloads it viaGet(), so theCalcFields-based read path used by the page is exercised — not just an in-memory roundtrip.I do not have a BC container available in this environment to execute the AL tests, so I am relying on CI to run them. They have been written so they fail against the previous binary
Write/Readcode and pass against theWriteText/ReadTextfix.Risk & compatibility
AIT Log Entry,149034) inside the AI Test Toolkit. No schema change and no public API change.Writecode will still contain the leading length bytes. Reading them withReadTextreturns the text including those leading bytes, which is what the page already mishandled — so no new data corruption, and any new entry written after this fix is read back cleanly. If preserving access to legacy rows is needed, a follow-up data-fix can be considered, but it is out of scope here.