microsoft / azuredatastudio-postgresql

azuredatastudio-postgresql is an extension for Azure Data Studio that enables you to work with PostgreSQL databases
Other
192 stars 37 forks source link

dictionary update sequence element #1 has length 1; 2 is required #434

Closed Reedlula closed 12 months ago

Reedlula commented 1 year ago

Type: Bug

Everything was working as expected. but then it looks like there was an update to the potgresql extension and I get the error: when trying to login.

dictionary update sequence element #1 has length 1; 2 is required

To produce I insert my AD credentials and click connect and this pops up. I have followed the steps here: https://github.com/microsoft/azuredatastudio-postgresql/issues/421

I get the same result. I have also updated my ADS and the same error persists

Extension version: 0.4.2 Azure Data Studio version: azuredatastudio 1.44.1 (8f53a316fa00a98264f1ab119641cd540b5af25c, 2023-06-01T02:12:48.765Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No Preview Features: Enabled Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 x 2592)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|15.83GB (4.71GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
murlakatam commented 1 year ago

Same problem here, using Azure Active Directory authentication type with a custom user name (role). Tried both ADS insiders and latest stable

The only workaround atm is downgrade to https://github.com/microsoft/azuredatastudio-postgresql/releases/download/v0.3.1/azuredatastudio-postgresql-0.3.1-win-x64.vsix manually

and disable automatic extension updates image

mariostrd commented 1 year ago

Same problem here, using Azure Active Directory authentication type with a custom user name (role). Tried both ADS insiders and latest stable

The only workaround atm is downgrade to https://github.com/microsoft/azuredatastudio-postgresql/releases/download/v0.3.1/azuredatastudio-postgresql-0.3.1-win-x64.vsix manually

and disable automatic extension updates image

Thanks murlakatam can confirm it works

Reedlula commented 1 year ago

Thanks @murlakatam that worked

murlakatam commented 1 year ago

Don't close the issue please @Reedlula, latest version still needs fixing

Reedlula commented 1 year ago

Done

DaeunYim commented 1 year ago

Hello, thanks for reporting the issue.

I was unable to reproduce this error. I attempted an AAD connection to an Azure PostgreSQL server on both Windows 10 and 11, using ADS PG extensions 0.3 and 0.4, as well as ADS version 1.44 and previous versions. I did not encounter any errors.

There have been some new binaries introduced in the 0.4 version, and they may be related to the issue. Could you please follow the steps below to clean up your environment?

Navigate to "C:\Users.azuredatastudio\extensions" and delete any existing PostgreSQL extensions. Don't worry about losing your connection information, as they will reappear once you reinstall the extension.

Open your file explorer and go to the "%temp%" location. Remove any folders named "_MEI<6digit number>" if they exist.

Once you have completed these steps, please try downloading and installing the new version of the PostgreSQL extension again.

Please let us know if this resolves the issue or if you need any further assistance.

murlakatam commented 1 year ago

Thanks for getting back to us @DaeunYim the issue is still reproducible after full cleanup

image

DaeunYim commented 1 year ago

Thanks @murlakatam. Couuld you check these folders and see if there's any other error logs? C:\Users\\AppData\Roaming\azuredatastudio\logs (esp. C:\Users\daeunyim\AppData\Roaming\azuredatastudio\logs\\exthost1) C:\Users\\AppData\Roaming\sqlops\pgsql

murlakatam commented 1 year ago

I've enabled debug mode in ADS and got this out. @DaeunYim

[2023-07-20 12:53:46.152] [renderer1] [debug] Read accounts from memento [<trimmed_data>] 
[2023-07-20 12:53:46.152] [renderer1] [debug] Read accounts from memento [<trimmed_data>] 
[2023-07-20 12:53:46.152] [renderer1] [debug] Getting security token for Azure account <trimmed_data>
[2023-07-20 12:53:46.173] [renderer1] [debug] Read accounts from memento [<trimmed_data>] 
[2023-07-20 12:53:46.174] [renderer1] [debug] Read accounts from memento [<trimmed_data>] 
[2023-07-20 12:53:46.186] [renderer1] [debug] Got access token for tenant <trimmed_data> that expires in -1688124609.348 seconds
[2023-07-20 12:53:46.187] [renderer1] [info] Creating new connection connection:providerName:PGSQL|applicationName:azdata|authenticationType:AzureMFAAndUser|dbname:postgres|host:<trimmeddata>.postgres.database.azure.com|hostaddr:|port:|user:<trimmed_role_name_with_spaces>|databaseDisplayName:postgres|group:<trimmed_guid>
[2023-07-20 12:53:46.187] [renderer1] [info] Adding connection connection:providerName:PGSQL|applicationName:azdata|authenticationType:AzureMFAAndUser|dbname:postgres|host:<trimmeddata>.postgres.database.azure.com|hostaddr:|port:|user:<trimmed_role_name_with_spaces>|databaseDisplayName:postgres|group:<trimmed_guid>
[2023-07-20 12:53:46.187] [renderer1] [info] Successfully added connection connection:providerName:PGSQL|applicationName:azdata|authenticationType:AzureMFAAndUser|dbname:postgres|host:<trimmeddata>.postgres.database.azure.com|hostaddr:|port:|user:<trimmed_role_name_with_spaces>|databaseDisplayName:postgres|group:<trimmed_guid>
[2023-07-20 12:53:46.508] [renderer1] [info] Error occurred while connecting, removing connection management info for connection:providerName:PGSQL|applicationName:azdata|authenticationType:AzureMFAAndUser|dbname:postgres|host:<trimmeddata>.postgres.database.azure.com|hostaddr:|port:|user:<trimmed_role_name_with_spaces>|databaseDisplayName:postgres|group:<trimmed_guid>
[2023-07-20 12:53:46.509] [renderer1] [info] Deleting connection connection:providerName:PGSQL|applicationName:azdata|authenticationType:AzureMFAAndUser|dbname:postgres|host:<trimmeddata>.postgres.database.azure.com|hostaddr:|port:|user:<trimmed_role_name_with_spaces>|databaseDisplayName:postgres|group:<trimmed_guid>
[2023-07-20 12:53:46.511] [renderer1] [error] dictionary update sequence element #1 has length 1; 2 is required
[2023-07-20 12:53:46.524] [renderer1] [debug] ConnectionDialogService: Connection error: dictionary update sequence element #1 has length 1; 2 is required

unfortunately it doesn't have much more info than in the screenshot. there is nothing relevant in exthost1 apart from

Downloading https://github.com/Microsoft/pgtoolsservice/releases/download/v1.8.0/pgsqltoolsservice-win-x64.zip
(182795 KB)....................Done!
Installing pgSQLToolsService to c:\Users\BaranovskyE\.azuredatastudio\extensions\microsoft.azuredatastudio-postgresql-0.4.2\out\ossdbtoolsservice\Windows\v1.8.0
Installed

in pgsql logs

2023-07-20 12:31:14,131 INFO PGSQL Tools Service is starting up...
2023-07-20 12:31:14,131 INFO Admin service successfully initialized
2023-07-20 12:31:14,132 INFO Language Service Operations Queue starting...
2023-07-20 12:31:14,133 INFO Metadata service successfully initialized
2023-07-20 12:31:14,133 INFO Object Explorer service successfully initialized
2023-07-20 12:31:14,133 INFO Query execution service successfully initialized
2023-07-20 12:31:14,133 INFO Scripting service successfully initialized
2023-07-20 12:31:14,133 INFO Edit data service successfully initialized
2023-07-20 12:31:14,133 INFO JSON RPC server starting...
2023-07-20 12:31:14,134 INFO Output thread started
2023-07-20 12:31:14,134 INFO Input thread started
2023-07-20 12:31:14,134 INFO Received request id=0 method=initialize
2023-07-20 12:31:14,135 INFO ResponseSuccess message sent id=0 method=None
2023-07-20 12:31:14,138 INFO Received notification method=initialized
2023-07-20 12:31:14,138 WARNING Notification method initialized is unsupported
2023-07-20 12:31:14,138 INFO Received notification method=workspace/didChangeConfiguration
2023-07-20 12:31:14,139 INFO Received notification method=textDocument/didOpen
2023-07-20 12:31:14,139 INFO Received notification method=textDocument/didOpen
2023-07-20 12:31:14,139 INFO Received notification method=textDocument/didOpen
2023-07-20 12:31:14,140 INFO Received request id=1 method=capabilities/list
2023-07-20 12:31:14,144 INFO ResponseSuccess message sent id=1 method=None
2023-07-20 12:31:24,069 WARNING JSON RPC Reader reached end of stream
2023-07-20 12:31:24,069 ERROR Thread JSON_RPC_Input_Thread encountered exception End of stream reached, no output.
Traceback (most recent call last):
  File "ossdbtoolsservice\hosting\json_rpc_server.py", line 208, in _consume_input
  File "ossdbtoolsservice\hosting\json_reader.py", line 70, in read_message
  File "ossdbtoolsservice\hosting\json_reader.py", line 127, in _read_next_chunk
EOFError: End of stream reached, no output.
2023-07-20 12:31:24,070 INFO JSON RPC server stopping...
2023-07-20 12:31:24,071 INFO Input and output threads have completed
2023-07-20 12:33:39,691 INFO PGSQL Tools Service is starting up...
2023-07-20 12:33:39,691 INFO Admin service successfully initialized
2023-07-20 12:33:39,691 INFO Language Service Operations Queue starting...
2023-07-20 12:33:39,692 INFO Metadata service successfully initialized
2023-07-20 12:33:39,693 INFO Object Explorer service successfully initialized
2023-07-20 12:33:39,693 INFO Query execution service successfully initialized
2023-07-20 12:33:39,693 INFO Scripting service successfully initialized
2023-07-20 12:33:39,693 INFO Edit data service successfully initialized
2023-07-20 12:33:39,693 INFO JSON RPC server starting...
2023-07-20 12:33:39,693 INFO Output thread started
2023-07-20 12:33:39,694 INFO Input thread started
2023-07-20 12:33:39,694 INFO Received request id=0 method=initialize
2023-07-20 12:33:39,695 INFO ResponseSuccess message sent id=0 method=None
2023-07-20 12:33:39,702 INFO Received notification method=initialized
2023-07-20 12:33:39,702 WARNING Notification method initialized is unsupported
2023-07-20 12:33:39,702 INFO Received notification method=workspace/didChangeConfiguration
2023-07-20 12:33:39,702 INFO Received notification method=textDocument/didOpen
2023-07-20 12:33:39,702 INFO Received notification method=textDocument/didOpen
2023-07-20 12:33:39,703 INFO Received notification method=textDocument/didOpen
2023-07-20 12:33:39,704 INFO Received request id=1 method=capabilities/list
2023-07-20 12:33:39,708 INFO ResponseSuccess message sent id=1 method=None
2023-07-20 12:33:57,859 INFO Received request id=2 method=connection/connect
2023-07-20 12:33:57,932 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:33:57,933 INFO ResponseSuccess message sent id=2 method=None
2023-07-20 12:33:58,369 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:44:25,072 INFO Received request id=3 method=connection/connect
2023-07-20 12:44:25,320 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:44:25,321 INFO ResponseSuccess message sent id=3 method=None
2023-07-20 12:44:25,760 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:44:37,459 INFO Received request id=4 method=connection/connect
2023-07-20 12:44:37,461 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:44:37,461 INFO ResponseSuccess message sent id=4 method=None
2023-07-20 12:44:37,784 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:45:19,833 INFO Received request id=5 method=connection/connect
2023-07-20 12:45:20,066 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:45:20,067 INFO ResponseSuccess message sent id=5 method=None
2023-07-20 12:45:20,386 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:45:32,723 INFO Received request id=6 method=connection/connect
2023-07-20 12:45:32,725 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:45:32,725 INFO ResponseSuccess message sent id=6 method=None
2023-07-20 12:45:33,027 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:48:29,055 INFO Received request id=7 method=connection/connect
2023-07-20 12:48:29,284 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:48:29,285 INFO ResponseSuccess message sent id=7 method=None
2023-07-20 12:48:29,582 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:51:43,492 INFO Received request id=8 method=connection/connect
2023-07-20 12:51:43,645 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:51:43,645 INFO ResponseSuccess message sent id=8 method=None
2023-07-20 12:51:43,950 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:53:22,370 INFO Received request id=9 method=connection/connect
2023-07-20 12:53:22,522 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:53:22,522 INFO ResponseSuccess message sent id=9 method=None
2023-07-20 12:53:22,832 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:53:31,319 INFO Received request id=10 method=connection/connect
2023-07-20 12:53:31,323 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:53:31,323 INFO ResponseSuccess message sent id=10 method=None
2023-07-20 12:53:31,654 INFO Notification message sent id=None method=connection/complete
2023-07-20 12:53:46,189 INFO Received request id=11 method=connection/connect
2023-07-20 12:53:46,197 INFO Received notification method=connection/languageflavorchanged
2023-07-20 12:53:46,198 INFO ResponseSuccess message sent id=11 method=None
2023-07-20 12:53:46,504 INFO Notification message sent id=None method=connection/complete
DaeunYim commented 1 year ago

@murlakatam this is good start. Thanks for providing this! I'll do more investigation and get back to you :)

murlakatam commented 1 year ago

@DaeunYim I've sniffed around a little bit and found that the problem is in underlying https://github.com/microsoft/pgtoolsservice Primerly some breaking change was introduced in between versions 1.7.0 and 1.8.0

when I compiled the latest extension code with 1.7.0 everything started to work as before.

I believe here was the change from 1.7.0 to 1.8.0 https://github.com/microsoft/azuredatastudio-postgresql/commit/df71d45883a33f91ef28f4fbd6ce2950aca8de28#diff-62d443e406f673a82516f4c8a48c8bcb5e0c4d3a0ae3c4a0c48dd0cbe3857536

I've also tried v1.8.1-insiders image

v1.8.0-insiders image

with no luck

however it works fine with v1.7.1 image

so the breaking change must have been introduced in between 1.7.1 and 1.8.0 https://github.com/microsoft/pgtoolsservice/compare/v1.7.1...v1.8.0

@nasc17 FYI

murlakatam commented 1 year ago

I was able to figure out the exact point of the issue https://github.com/microsoft/pgtoolsservice/issues/445 apparently the trigger of the problem in our case is spaces in the username.

DaeunYim commented 1 year ago

@murlakatam Thank you for not only identifying the bug in our system, but also dedicating additional effort to debug it. We've incorporated the fix and plan to release the updated version by the end of this month.

DaeunYim commented 1 year ago

Closing after stable release

nasc17 commented 1 year ago

Hello, issue has been addressed in our unstable release of PostgreSQL extension v0.4.3-insiders. We would appreciate your verification that it has been handled appropriately.

murlakatam commented 1 year ago

@nasc17 I can confirm I can connect using v0.4.3-insiders with a username with spaces. No dictionary exception

murlakatam commented 1 year ago

@Reedlula works fine in latest stable 0.5.0 release.

nasc17 commented 12 months ago

Bug has been addressed in latest stable release of PostgreSQL extension v0.5.0. Please reopen if issue is still present, thank you.