Skip to content

Conversation

yileicn
Copy link
Collaborator

@yileicn yileicn commented Oct 13, 2025

PR Type

Bug fix


Description

  • Reversed priority in RoleContent getter for non-user roles

  • Now returns Content first, then falls back to RichContent.Message.Text


Diagram Walkthrough

flowchart LR
  A["RoleContent getter"] --> B{"Role == User?"}
  B -- "Yes" --> C["Return Payload or Content"]
  B -- "No" --> D["Return Content or RichContent.Message.Text"]
Loading

File Walkthrough

Relevant files
Bug fix
RoleDialogModel.cs
Reverse content priority in RoleContent getter                     

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs

  • Changed priority order in RoleContent getter for non-user roles
  • Now checks Content before RichContent.Message.Text instead of vice
    versa
+1/-1     

Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent potential null reference exception

Ensure the RoleContent property always returns a non-null string by coalescing a
potential null result to an empty string to prevent a possible
NullReferenceException.

src/Infrastructure/BotSharp.Abstraction/Conversations/Models/RoleDialogModel.cs [155]

-text = !string.IsNullOrWhiteSpace(Content) ? Content : RichContent?.Message?.Text;
+text = (!string.IsNullOrWhiteSpace(Content) ? Content : RichContent?.Message?.Text) ?? string.Empty;
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a scenario where the RoleContent property could return null, violating its non-nullable contract and potentially causing a NullReferenceException. The proposed fix is appropriate and improves code robustness.

Medium
  • More

@yileicn yileicn merged commit fd6d8fd into SciSharp:master Oct 13, 2025
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