Skip to content

Fix SetAnswerForQnAEvaluation: initialize Test Output Json before Add#7123

Open
DmitryKatson wants to merge 1 commit intomicrosoft:mainfrom
DmitryKatson:fix/ai-test-toolkit-set-answer-for-qna-initialize
Open

Fix SetAnswerForQnAEvaluation: initialize Test Output Json before Add#7123
DmitryKatson wants to merge 1 commit intomicrosoft:mainfrom
DmitryKatson:fix/ai-test-toolkit-set-answer-for-qna-initialize

Conversation

@DmitryKatson
Copy link
Contributor

Summary

SetAnswerForQnAEvaluation in AITTestContextImpl.Codeunit.al called CurrentTestOutputJson.Add(...) without first calling Initialize(), causing the runtime error:

The data output is not initialized or is of the wrong type. It must be an Json object or array.

Root cause

Codeunit "Test Output Json" requires Initialize() before any Add call. All other procedures in the same codeunit (SetQueryResponse, AddMessage, SetTestOutput) already call Initialize() correctly — SetAnswerForQnAEvaluation was the only one missing it.

Fix

Added CurrentTestOutputJson.Initialize(); as the first statement in SetAnswerForQnAEvaluation, before the first Add call, in src/Tools/AI Test Toolkit/src/AITTestContextImpl.Codeunit.al.

`SetAnswerForQnAEvaluation` was calling `CurrentTestOutputJson.Add(...)`
without first calling `Initialize()`, causing the runtime error:
"The data output is not initialized or is of the wrong type.
It must be an Json object or array."

Added the missing `CurrentTestOutputJson.Initialize()` call as the first
statement in the procedure body, consistent with `SetQueryResponse`,
`AddMessage`, and `SetTestOutput` in the same codeunit, all of which
already call `Initialize()` before using `Test Output Json`.
@DmitryKatson DmitryKatson requested a review from a team as a code owner March 13, 2026 11:14
@github-actions github-actions bot added AL: Tools From Fork Pull request is coming from a fork labels Mar 13, 2026
@github-actions
Copy link

Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link.

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

Labels

AL: Tools From Fork Pull request is coming from a fork

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant