Skip to content
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

Fix | The SqlConnection.FireInfoMessageEventOnUserErrors when set to true throws an exception #2399

Conversation

arellegue
Copy link
Contributor

Fixes #2388

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.84%. Comparing base (769b982) to head (2ddd21c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2399      +/-   ##
==========================================
- Coverage   72.71%   66.84%   -5.87%     
==========================================
  Files         310      304       -6     
  Lines       61885    61576     -309     
==========================================
- Hits        44997    41158    -3839     
- Misses      16888    20418    +3530     
Flag Coverage Δ
addons ∅ <ø> (∅)
netcore 71.01% <100.00%> (-5.91%) ⬇️
netfx 64.62% <100.00%> (-5.63%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@DavoudEshtehari DavoudEshtehari added this to the 6.0-preview1 milestone Mar 12, 2024
@DavoudEshtehari DavoudEshtehari added the 🐛 Bug! Something isn't right ! label Mar 12, 2024
@JRahnama
Copy link
Member

The proposed fix seems satisfactory for merging as it stands. However, it's important to note that this portion of the code was altered by #1825. Given that it introduces a new feature to the driver, it's essential to conduct a thorough review to ensure that the implementation behaves as intended in this particular scenario.

cc: @Wraith2

@DavoudEshtehari
Copy link
Member

Fix the title with a proper description, please.

@arellegue arellegue changed the title Fix | FixedFireInfoMessageEventOnUserErrorsThrowsExceptionWhenUsed Fix | The connection.FireInfoMessageEventOnUserErrors when set to true throws an exception Mar 12, 2024
@Wraith2
Copy link
Contributor

Wraith2 commented Mar 12, 2024

I'm intrigued. How have we managed to have to reach GetCurrentBatchCommand without executing an rpc? It should have gone through GetRPCObject in order to send anything to the server and so the rpc should be non-null.

@arellegue arellegue changed the title Fix | The connection.FireInfoMessageEventOnUserErrors when set to true throws an exception Fix | The SqlConnection.FireInfoMessageEventOnUserErrors when set to true throws an exception Mar 12, 2024
@JRahnama
Copy link
Member

I'm intrigued. How have we managed to have to reach GetCurrentBatchCommand without executing an rpc? It should have gone through GetRPCObject in order to send anything to the server and so the rpc should be non-null.

I am curious to understand why GetCurrentBatchCommand was added to that particular exception? GetRPCObject has not been called at that stage. I tested with Batch and it also came back null. I was wondering if we should let the default value of null to be passed on that call?

@Wraith2
Copy link
Contributor

Wraith2 commented Mar 15, 2024

If there is never a way to call the caller of GetCurrentBatchCommand in this situation and expect there to be a batch command then we should not make the call to GetCurrentBatchCommand and just use null. If it's possible then this nullable approach is fine. It seems odd that we could raise an exception through the command reporting path without even calling the server.

Copy link
Member

@DavoudEshtehari DavoudEshtehari left a comment

Choose a reason for hiding this comment

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

LGTM, waiting for the resolution by @JRahnama and @Wraith2.

@Wraith2
Copy link
Contributor

Wraith2 commented Mar 20, 2024

Ok. I debugged through it and understand the situation now. The library only needs to use an RPC object internally if there are parameters and in this case there aren't so it follows a path that simply sends the text without first building any sort of RPC. It'd be good to get this sort of breakdown as part of the fix so those of us following along at home can understand why the fix works.

It does raise a question or what happens if you try to setup a BatchCommand with a set of commands that have no parameters, would errors be reported correctly or crash?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug! Something isn't right !
Projects
None yet
5 participants