microsoft / go-sqlcmd

The new sqlcmd, CLI for SQL Server and Azure SQL (winget install sqlcmd / sqlcmd create mssql / sqlcmd open ads)
https://learn.microsoft.com/sql/tools/sqlcmd/go-sqlcmd-utility
MIT License
334 stars 58 forks source link

Error - panic: Invalid encryption method ("" not in "none, dpapi") #313

Closed yorek closed 1 year ago

yorek commented 1 year ago

With the latest 0.15.3 version I'm getting the following error:

> sqlcmd --version
panic: Invalid encryption method ("" not in "none, dpapi")

goroutine 1 [running]:
github.com/microsoft/go-sqlcmd/internal/secret.Decode({0xc0003904b0?, 0x44?}, {0x0, 0x0})
        D:/a/1/s/internal/secret/secret.go:50 +0x1e8
github.com/microsoft/go-sqlcmd/internal/config.GetCurrentContextInfo()
        D:/a/1/s/internal/config/context.go:107 +0x167
main.initializeEnvVars()
        D:/a/1/s/cmd/modern/main.go:83 +0xcf
main. Main()
        D:/a/1/s/cmd/modern/main.go:51 +0x20c
stuartpa commented 1 year ago

Simole fix is in the release notes. (You have a sqlconfig file from an older release)

yorek commented 1 year ago

Got it, thanks!

stuartpa commented 1 year ago

From release notes fix is:

NOTE: For users of previous versions, if you have an old sqlconfig file, and get a "panic: Invalid encryption method", edit the ~/.sqlcmd/sqlconfig file and replace "password-encrypted: false" to "password-encryption: none".

You won't see this in the next dot release.

yorek commented 1 year ago

So, shouldn't be the config file now set to "v2"? That way you can easily raise an more friendly error if a previous version is detected. (or, even better, just automatically update). Using winget I have no way to get to the release notes.

stuartpa commented 1 year ago

This was just a bug, a file didn't get checked in off my machine. But yes, in the future we need full version support for the sqlconfig schema.