QnAPrompting sample does not deserialize metadata tags correctly
Sample information
- Sample type: \samples\experimental\qnamaker-prompting
- Sample language: dotnetcore
- Sample name: QnAPrompting
Describe the bug
When the QnA KB is queried with a question where the answer contains metadata tags, the metadata in the result returned by QnAService.QueryQnAServiceAsync is null. This is because in QnAResult.cs, Metadata is defined with { get; } instead of { get; set; }.
To Reproduce
Steps to reproduce the behavior:
- Go to the QnA KB being used for testing
- Add a metadata tag to one of the question-answer pairs
- Click Save and train
- Click the Publish tab, and then click Publish
- Run the QnAPrompting sample, and set a breakpoint in QnAService.QueryQnAServiceAsync at the line containing return result.Answers;
- Start the emulator and connect it to the QnAPrompting bot
- In the emulator, enter the question where you added a metadata tag
- At the breakpoint, examine Metadata in result.Answers. You will see that it is null for all answers, including the answer that has a metadata tag
Expected behavior
For the answer that has a metadata tag, Metadata should contain the metadata tag name and value.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
This bug can be fixed by modifying QnAResult.cs at the line where Metadata is defined, to change {get; } to {get; set; }
[bug]
Hey @rokulka , can you look at this customer issue? Thanks.
@rokulka wanted to chime in that I was able to repro what @kds-snyder reported and adding screen shots for context
Running qnamaker-prompting sample as is
My KB - Q&A pairs with metadata

Breakpoint to view qnaResult in QnADialog.cs.
Metadataisnullfor all results returned fromgenerateAnswerAPI call
Updating QnAResult.cs
- Updated to
public QnAMetadata[] Metadata { get; set; }
Breakpoint again to view qnaResult in QnADialog.cs with being able to set Metadata

- Metadata for an answer without
Metadatais now[] - For answers with
Metadata, results now properly showMetadata[]
I'm looking into it.
Hi @kds-snyder : Thanks again for reporting. Let us know if this doesn't address your issue.
@axelsrz, @rokulka, @Zerryth, @trojenguri, @daveta, thanks for your quick resolution of this issue.