Skip to content

Conversation

iceljc
Copy link
Collaborator

@iceljc iceljc commented Sep 1, 2025

PR Type

Bug fix


Description

  • Fix null reference exception in payload processing

  • Add null check before accessing item.Value.DataValue

  • Improve validation logic for payload items


Diagram Walkthrough

flowchart LR
  A["Payload Item"] --> B["Null Check Added"]
  B --> C["Safe DataValue Access"]
  C --> D["String Conversion"]
Loading

File Walkthrough

Relevant files
Bug fix
QdrantDb.cs
Fix null reference in payload processing                                 

src/Plugins/BotSharp.Plugin.Qdrant/QdrantDb.cs

  • Add null check for item.Value before accessing DataValue
  • Restructure validation logic to prevent null reference exceptions
  • Separate null value check from string conversion validation
+6/-1     

Copy link

qodo-merge-pro bot commented Sep 1, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Behavior Change

The previous logic skipped when value was null OR when the key matched KnowledgePayloadName.Text. The new logic skips early for null values or the specific key, and then additionally skips when the converted string is empty. Validate that treating empty strings the same as null is intended and won’t exclude legitimate empty payloads.

if (item.Value == null || item.Key.IsEqualTo(KnowledgePayloadName.Text))
{
    continue;
}

var value = item.Value.DataValue?.ConvertToString();
if (string.IsNullOrEmpty(value))
{
    continue;
Key Comparison

The key exclusion check item.Key.IsEqualTo(KnowledgePayloadName.Text) was moved before accessing DataValue. Confirm that item.Key cannot be null and that IsEqualTo handles nulls/whitespace consistently to avoid unexpected skips or exceptions.

if (item.Value == null || item.Key.IsEqualTo(KnowledgePayloadName.Text))
{
    continue;
}

Copy link

qodo-merge-pro bot commented Sep 1, 2025

PR Code Suggestions ✨

No code suggestions found for the PR.

@iceljc iceljc merged commit 007f96c into SciSharp:master Sep 1, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant