Description
When I attempt to provide a connection string via a SecureString/PassowrdString (or secret variable) in a Polyglot Notebook using the #!connect mssql
magic command, I get the error: Format of the initialization string does not conform to specification starting at index 0.
This prevents the connection string from being hidden, as it fails to parse from the secured variable. (first screenshot)
When the password is provided in clear text, the connection succeeds, confirming that the variable’s content is correct. (second screenshot)
Additional Context:
Notebook
#!meta
{"kernelInfo":{"defaultKernelName":"csharp","items":[{"aliases":[],"languageName":"csharp","name":"csharp"},{"aliases":[],"languageName":"T-SQL","name":"sql-Integration_myCompany"}]}}
#!pwsh
Get-SecretInfo -Vault DotnetInteractive;
#!csharp
#!set --name myCompanyIntegrationSql --value @password:{"saveAs":"myCompany.integration.sql", "prompt":"Please provide a connection string."}
#!markdown
## Load SQL Library
#!csharp
#r "nuget:Microsoft.DotNet.Interactive.SqlServer,*-*"
//var connectionString = myCompanyIntegrationSql.GetClearTextPassword();
//myCompanyIntegrationSql.GetClearTextPassword().Display();
#!csharp
#!connect mssql --kernel-name Integration_myCompany --connection-string @myCompanyIntegrationSql
Stack
Error: System.Exception: Format of the initialization string does not conform to specification starting at index 0.
at Microsoft.DotNet.Interactive.SqlServer.MsSqlKernel.ConnectAsync()
at Microsoft.DotNet.Interactive.SqlServer.MsSqlKernelConnector.CreateKernelAsync(String kernelName)
at Microsoft.DotNet.Interactive.SqlServer.ConnectMsSqlDirective.ConnectKernelsAsync(ConnectMsSqlKernel connectCommand, KernelInvocationContext context)
at Microsoft.DotNet.Interactive.CompositeKernel.ConnectKernel[TCommand](TCommand command, ConnectKernelDirective`1 connectDirective, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\CompositeKernel.cs:line 253
at Microsoft.DotNet.Interactive.CompositeKernel.<>c__DisplayClass20_0`1.<<AddConnectDirective>b__0>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\CompositeKernel.cs:line 238
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 365
at Microsoft.DotNet.Interactive.CompositeKernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\CompositeKernel.cs:line 194
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 60
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_1.<<BuildPipeline>b__3>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 75
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.App.KernelExtensions.<>c__DisplayClass5_0.<<UseTelemetrySender>b__0>d.MoveNext() in D:\a\_work\1\s\src\dotnet-interactive\KernelExtensions.cs:line 296
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_1.<<BuildPipeline>b__3>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 75
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.App.KernelExtensionLoader.<>c__DisplayClass0_0.<<UseNuGetExtensions>b__0>d.MoveNext() in D:\a\_work\1\s\src\dotnet-interactive\KernelExtensionLoader.cs:line 25
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_1.<<BuildPipeline>b__3>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 75
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.App.KernelExtensions.<>c__DisplayClass4_0.<<UseSecretManager>b__0>d.MoveNext() in D:\a\_work\1\s\src\dotnet-interactive\KernelExtensions.cs:line 227
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_0.<<BuildPipeline>g__Combine|2>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 73
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_0.<<BuildPipeline>g__Combine|2>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 73
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_0.<<BuildPipeline>g__Combine|2>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 73
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 41
Note
I initially raised this topic in a #3789, and now I'm creating this issue to track what appears to be a bug and continue the conversation here.
Screenshots
Please complete the following:
Which version of .NET Interactive are you using? (In a notebook, run the #!about
magic command. ):
- OS
- Windows 11
- Windows 10
- macOS
- Linux (Please specify distro)
- iOS
- Android
- Browser
- Chrome
- Edge
- Firefox
- Safari
- Frontend
- Jupyter Notebook
- Jupyter Lab
- nteract
- Visual Studio Code
- Visual Studio Code Insiders
- Visual Studio
- Other (please specify)