-
Notifications
You must be signed in to change notification settings - Fork 321
Fixing NullReferenceException issue with SqlDataAdapter #3857
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
Fixing NullReferenceException issue with SqlDataAdapter #3857
Conversation
There was a problem hiding this 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.Lengthto 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) |
Copilot
AI
Dec 22, 2025
There was a problem hiding this comment.
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.
apoorvdeshmukh
left a comment
There was a problem hiding this 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?
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