Skip to content
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

Merged

Conversation

Ahmed-Adel3
Copy link
Contributor

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

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.
@github-actions github-actions bot added the webapi Pull requests that update .net code label Oct 25, 2023
@crickman
Copy link
Contributor

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 Details is referenced.

@crickman crickman self-requested a review October 26, 2023 15:40
@crickman crickman added the PR: paused For PRs that have been converted to draft, are facing blockers or have no active development planned label Oct 26, 2023
@Ahmed-Adel3
Copy link
Contributor Author

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 Details is referenced.

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 Details is only referenced in the SemanticChatMemoryItem in the class constructor and the ToFormattedString function.

@crickman
Copy link
Contributor

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)

@crickman crickman enabled auto-merge October 26, 2023 16:05
@crickman crickman added this pull request to the merge queue Oct 26, 2023
Merged via the queue into microsoft:main with commit fd823d3 Oct 26, 2023
Ryangr0 pushed a commit to webgrip/chat-copilot that referenced this pull request Oct 26, 2023
### 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 😄
teamleader-dev pushed a commit to vlink-group/chat-copilot that referenced this pull request Oct 7, 2024
### 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 😄
kb0039 pushed a commit to aaronba/chat-copilot that referenced this pull request Jan 8, 2025
### 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 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: paused For PRs that have been converted to draft, are facing blockers or have no active development planned webapi Pull requests that update .net code
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

2 participants