Skip to content

Conversation

@priyankatiwari08
Copy link
Contributor

Description

This Pull Request addresses issue #3716 by introducing a null check for systemParams, which stores the system-level parameters for SQL RPC (Remote Procedure Call) operations. In batch scenarios, certain SQL RPC calls may not include system parameters, and this change ensures proper handling in such cases.

Issues

#3716

Copilot AI review requested due to automatic review settings December 22, 2025 09:24
@priyankatiwari08 priyankatiwari08 requested a review from a team as a code owner December 22, 2025 09:24
@priyankatiwari08 priyankatiwari08 added this to the 7.0.0-preview4 milestone Dec 22, 2025
Copy link
Contributor

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

This PR fixes a NullReferenceException in SqlDataAdapter when processing batch RPC operations with Always Encrypted. The issue occurs when systemParams is null in batch scenarios where SQL RPC calls don't include system-level parameters.

  • Adds null check before accessing systemParams.Length to prevent NullReferenceException
  • Protects the encryption metadata fetching logic in batch RPC mode from operating on null arrays
  • Ensures proper handling of RPC objects created with zero system parameters

// input parameters start at parameters[1]. parameters[0] is the actual
// T-SQL Statement. rpcName is sp_executesql.
if (_RPCList[i].systemParams.Length > 1)
if (_RPCList[i].systemParams != null && _RPCList[i].systemParams.Length > 1)
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

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

The null check added here is correct and necessary to prevent NullReferenceException in batch scenarios. However, there doesn't appear to be a test case that covers this specific scenario - batching with Always Encrypted where systemParams could be null. Consider adding a test that exercises this code path to prevent regression.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@apoorvdeshmukh apoorvdeshmukh left a comment

Choose a reason for hiding this comment

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

Please open another issue to track the pending testcase for this change.
Since we have a repro for this issue, can you add details about how this change was validated?

@paulmedynski paulmedynski self-assigned this Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants