-
Notifications
You must be signed in to change notification settings - Fork 709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SemanticChatMemoryItem.cs #542
Update SemanticChatMemoryItem.cs #542
Conversation
Fix null reference in ToFormattedString function In the `SemanticChatMemoryItem.ToFormattedString` function, ensure that the `Details` property is not null before trimming it. This change prevents potential NullReferenceExceptions when the `Details` property is null. This modification ensures the stability of the `ToFormattedString` function when used in other parts of the code.
Nice clean change, thank you! Just to confirm, you experienced null-ref exception on this line? (Just double-checking because of the nullable project settings and type declaration - not nullable.) In the meantime, I'm just curious to see where else |
Thanks @crickman for your reply, Yes, I experienced the Null reference exception in this line, happened twice while I was running the Chat Copilot locally, but unfortunately didn't catch the scenario. I'll try to reproduce it and if so, I may open an issue if it's caused by a bug. I can see that |
Wonderful, thanks for the quick reply. The nullable stuff isn't air-tight so I'm not surprised...probably serialization related (components outside of the project scope aren't bound to nullability hints - e.g. jsonserializer) |
### Motivation and Context 1. Why is this change required? Possible Null reference exception. 2. What problem does it solve? Fix null reference in ToFormattedString function 3. What scenario does it contribute to? If ( Item ) object label and Details are null. ### Description In the `SemanticChatMemoryItem.ToFormattedString` function, ensure that the `Details` property is not null before trimming it. This change prevents potential NullReferenceExceptions when the `Details` property is null. This modification ensures the stability of the `ToFormattedString` function when used in other parts of the code. ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
### Motivation and Context 1. Why is this change required? Possible Null reference exception. 2. What problem does it solve? Fix null reference in ToFormattedString function 3. What scenario does it contribute to? If ( Item ) object label and Details are null. ### Description In the `SemanticChatMemoryItem.ToFormattedString` function, ensure that the `Details` property is not null before trimming it. This change prevents potential NullReferenceExceptions when the `Details` property is null. This modification ensures the stability of the `ToFormattedString` function when used in other parts of the code. ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
### Motivation and Context 1. Why is this change required? Possible Null reference exception. 2. What problem does it solve? Fix null reference in ToFormattedString function 3. What scenario does it contribute to? If ( Item ) object label and Details are null. ### Description In the `SemanticChatMemoryItem.ToFormattedString` function, ensure that the `Details` property is not null before trimming it. This change prevents potential NullReferenceExceptions when the `Details` property is null. This modification ensures the stability of the `ToFormattedString` function when used in other parts of the code. ### Contribution Checklist - [x] The code builds clean without any errors or warnings - [x] The PR follows the [Contribution Guidelines](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/chat-copilot/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [x] I didn't break anyone 😄
Motivation and Context
Description
In the
SemanticChatMemoryItem.ToFormattedString
function, ensure that theDetails
property is not null before trimming it. This change prevents potential NullReferenceExceptions when theDetails
property is null.This modification ensures the stability of the
ToFormattedString
function when used in other parts of the code.Contribution Checklist