rebus-org / Rebus.SqlServer

:bus: Microsoft SQL Server transport and persistence for Rebus
https://mookid.dk/category/rebus
Other
43 stars 42 forks source link

Error in connectionString leads to application crash without exception - Swallow innerexception #94

Closed mathiash98 closed 2 years ago

mathiash98 commented 2 years ago

Had an issue where we had connectionstring like: Server=tcp:xxx.database.windows.net,1433;Inital Catalog=sqldb_event_bus-staging;Persist Security Info=False;User ID=admin;Password=password;" Where Initial Catalog was wrongly typed leading to unsuccessful connection.

To debug further I disabled "just my code" in Visual Studio and found that we got 'System.ArgumentException' in System.Private.CoreLib.dll saying: Keyword not supported: 'inital catalog'.'. Further stepping in debug showed that innerException was kept for some stacks in Rebus. But then it got swallowed and crashed application.

So the innerException should be thrown all the way out to where the application is crashing.

mookid8000 commented 2 years ago

Thanks for reporting this! However... 😉

I just tried to replicate the issue using this test case, but I could not make it lose the inner exception in any of the cases.

A malformed connection string was used for transport, subscriptions, sagas, timeouts, and the outbox, but they all gave me an error message like this:

Rebus.Injection.ResolutionException: Could not resolve Rebus.Subscriptions.ISubscriptionStorage with decorator depth 0 - registrations: Rebus.Injection.Injectionist+Handler
 ---> System.ArgumentException: Keyword not supported: 'inital catalog'.
   at Microsoft.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
   at Microsoft.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms)
   at Microsoft.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
(...)

i.e. with a ResolutionException wrapping an ArgumentException.

I suspect you have somehow lost the inner exception somewhere else outside of Rebus... I'll close this issue for now, let me know if there's something I've missed in my attempt to replicate your issue 🙂

mathiash98 commented 2 years ago

Thank you for the time spent

mookid8000 commented 2 years ago

No problem! It's a good opportunity to get this particular area covered by tests 🙂