Skip to content

Fix NullReferenceException when evaluating `RunStepDetailsUpdate.FunctionName #50382

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

crickman
Copy link

@crickman crickman commented Jun 3, 2025

_asFunctionCall may be null for a non-function related tool. All other properties support null fall-through.

Contributing to the Azure SDK

Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.

For specific information about pull request etiquette and best practices, see this section.

@Copilot Copilot AI review requested due to automatic review settings June 3, 2025 16:30
@github-actions github-actions bot added AI Model Inference AI Projects Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jun 3, 2025
Copy link

github-actions bot commented Jun 3, 2025

Thank you for your contribution @crickman! We will review the pull request and get back to you soon.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes a null reference when accessing FunctionName on RunStepDetailsUpdate by adding null propagation to _asFunctionCall.

  • Added a null check on _asFunctionCall before accessing Function.Name to prevent NullReferenceException.

@@ -46,7 +46,7 @@ public IReadOnlyList<RunStepDeltaCodeInterpreterOutput> CodeInterpreterOutputs
=> _asCodeCall?.CodeInterpreter?.Outputs;

/// <inheritdoc cref="RunStepDeltaFunction.Name"/>
public string FunctionName => _asFunctionCall.Function?.Name;
public string FunctionName => _asFunctionCall?.Function?.Name;
Copy link
Preview

Copilot AI Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FunctionName property now returns null when _asFunctionCall is null, but its return type is declared as non-nullable string. Consider changing the return type to string? to accurately reflect nullability or provide a default value with the null-coalescing operator (e.g., ?? string.Empty).

Copilot uses AI. Check for mistakes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true for all properties in this class (see FunctionArguments). Project is not setting <Nullable>true</Nullable>. Best to match the current convention.

@crickman
Copy link
Author

crickman commented Jun 3, 2025

@dargilco / @jhakulin - Can you please take a look at this fix? Looks like a simple oversight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Model Inference AI Projects Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant