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

object has no attribute 'encode #449

Closed mstein-IDEX closed 8 months ago

mstein-IDEX commented 12 months ago

Type: Bug

Hello,

when I run the following query I get an error "Unhandled exception while executing query: 'IPv4Address' object has no attribute 'encode'"

select asset_id ,mac_address ,ip_address from public.dim_asset

Table Schema located here. https://help.rapid7.com/nexpose/en-us/warehouse/warehouse-schema.html#dim_asset.ip_address

Azure Data Studio version: azuredatastudio 1.45.0 (8eff468100f02157f2219335f7a566d14451ca49, 2023-07-24T18:22:12.106Z) OS version: Windows_NT x64 10.0.22621 Restricted Mode: No Preview Features: Enabled Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 1805)| |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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|31.73GB (12.51GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (1) Extension|Author (truncated)|Version ---|---|--- azuredatastudio-postgresql|Mic|0.5.0
cheenamalhotra commented 12 months ago

@mstein-IDEX

Do you also experience similar error with SSMS 19?

mstein-IDEX commented 12 months ago

I have not loaded SQL Server Management Studio 19.1 but will this morning.

Update loading now......

mstein-IDEX commented 12 months ago

Just installed SSMS 19 with azure data studio.

I have the same issues, what else can I test?

image

cheenamalhotra commented 12 months ago

I meant can you run your query on SSMS and let us know if this issue occurs there too?

mstein-IDEX commented 12 months ago

So this is a postgres DB, I'll see if it can connect

cheenamalhotra commented 12 months ago

Oh, sorry I thought this was MSSQL, never mind. I will transfer to PostgreSQL extension repo.

mstein-IDEX commented 11 months ago

Apologies I have been away any update?

philcruz commented 11 months ago

I running into this error as well (when I query tables with IP addresses using steampipe.io)

Version: 1.45.1 Commit: 88c21b1725a3e79440027bdb7b5a55fb036be0e2 Date: 2023-08-03T00:42:36.656Z VS Code: 1.79.2 Electron: 22.3.14 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Darwin x64 22.5.0

nasc17 commented 11 months ago

We are currently working on solution. We will send update when fix can first be tested from the insiders release.

mstein-IDEX commented 11 months ago

BTW I also see this issue with PowerBI not sure if it's related.

thanks

nasc17 commented 11 months ago

Bug has been addressed in our unstable release of PostgreSQL extension v0.5.1-insiders. We would appreciate your verification that it has been handled appropriately.

mstein-IDEX commented 11 months ago

I loaded the new release and was able to execute the PostgreSQL without any issues.

Thanks

From: nasc17 @.> Sent: Tuesday, August 29, 2023 3:51 PM To: microsoft/azuredatastudio-postgresql @.> Cc: Steinbach, Mark @.>; Author @.> Subject: Re: [microsoft/azuredatastudio-postgresql] object has no attribute 'encode (Issue #449)

Bug has been addressed in our unstable release of PostgreSQL extension v0. 5. 1-insiders. We would appreciate your verification that it has been handled appropriately. — Reply to this email directly, view it on GitHub, or unsubscribe. You

Bug has been addressed in our unstable release of PostgreSQL extension v0.5.1-insidershttps://urldefense.com/v3/__https:/github.com/microsoft/azuredatastudio-postgresql/releases/tag/v0.5.1-insiders__;!!NlLrMPuo!qy39dR6zXgt1SQotelu0r26rj92kMs537pWH8Gub_ZXQuoRKeqIV6c0VdPD6y8ljEN2ogwiySzxEUOmzlbgmbddVkgw$. We would appreciate your verification that it has been handled appropriately.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/microsoft/azuredatastudio-postgresql/issues/449*issuecomment-1698111662__;Iw!!NlLrMPuo!qy39dR6zXgt1SQotelu0r26rj92kMs537pWH8Gub_ZXQuoRKeqIV6c0VdPD6y8ljEN2ogwiySzxEUOmzlbgmXUh1iLI$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/A2GS3XGTPBX4CX3TT7EPWV3XXZI4NANCNFSM6AAAAAA3DG76OI__;!!NlLrMPuo!qy39dR6zXgt1SQotelu0r26rj92kMs537pWH8Gub_ZXQuoRKeqIV6c0VdPD6y8ljEN2ogwiySzxEUOmzlbgmimbKhRQ$. You are receiving this because you authored the thread.Message ID: @.**@.>>


This e-mail is intended solely for the intended recipient or recipients. If this e-mail is addressed to you in error or you otherwise receive this e-mail in error, please advise @.*** as well as the sender, do not read, print, forward or save this e-mail, and promptly delete and destroy all copies of this e-mail. If you would like additional information regarding how your data is collected, used and/or disclosed by IDEX or its business units please consult the IDEX Business Contact Privacy Notice https://www.idexcorp.com/business-contact-privacy-notice/ . This email may contain information that is confidential, proprietary or secret and should be treated as confidential by all recipients. This e-mail may also be a confidential attorney-client communication, contain attorney work product, or otherwise be privileged and exempt from disclosure. If there is a confidentiality or non-disclosure agreement or protective order covering any information contained in this e-mail, such information shall be treated as confidential and subject to restriction on disclosure and use in accordance with such agreement or order, and this notice shall constitute identification, labeling or marking of such information as confidential, proprietary or secret in accordance with such agreement or order. The term 'this e-mail' includes any and all attachments.


caioeps commented 11 months ago

I loaded the new ARM64 OSX 0.5.1-insiders release, and I cannot connect to any database now. I getting this error:

image

Here's what I have in the logs:

[Error - 2:49:37 PM] Starting client failed
Launching server using command /Users/caioergos/.azuredatastudio/extensions/microsoft.azuredatastudio-postgresql-0.5.1/out/ossdbtoolsservice/OSX_ARM64/v1.9.1-insiders/pgsqltoolsservice/ossdbtoolsservice_main failed.
nasc17 commented 11 months ago

Hi @caioeps , we discovered an issue with the ARM executable for insiders. Please revert back to our current stable release until we are able resolve this problem.

nasc17 commented 11 months ago

@caioeps the unstable release has been updated. Please inform us if same connection issue presents itself: https://github.com/microsoft/azuredatastudio-postgresql/releases/tag/v0.5.1-insiders

caioeps commented 10 months ago

@nasc17 Yeah, unfortunately the error persists.

[Error - 11:02:38 PM] Starting client failed
Launching server using command /Users/caioergos/.azuredatastudio/extensions/microsoft.azuredatastudio-postgresql-0.5.1/out/ossdbtoolsservice/OSX_ARM64/v1.9.1-insiders/pgsqltoolsservice/ossdbtoolsservice_main failed.
nasc17 commented 10 months ago

@nasc17 Yeah, unfortunately the error persists.

[Error - 11:02:38 PM] Starting client failed
Launching server using command /Users/caioergos/.azuredatastudio/extensions/microsoft.azuredatastudio-postgresql-0.5.1/out/ossdbtoolsservice/OSX_ARM64/v1.9.1-insiders/pgsqltoolsservice/ossdbtoolsservice_main failed.

Hi, thanks for the quick response.

There have been some new binaries introduced in the insiders build, and we suspect 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 0.5.1-insiders vsix of the PostgreSQL extension again.

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

Additional error logging you can check: C:\Users\AppData\Roaming\azuredatastudio\logs (esp. C:\Users\daeunyim\AppData\Roaming\azuredatastudio\logs\exthost1) C:\Users\AppData\Roaming\sqlops\pgsql

ps2goat commented 10 months ago

I was having the same original issue on Windows 10 22H2 with Azure Data Studio's latest builds, both regular and insider's. The extension of 0.5.0 did not work for either.

0.5.1-insiders works as expected! My queries are running and returning data.

If it matters, I've only tested running locally and using an IP address for the server/host (127.0.0.1).

gsl-pierrekore commented 10 months ago

The extension of 0.5.0 do not working for me either.

nasc17 commented 10 months ago

@gsl-pierrekore could you please provide us more information on how the extension is not working for you? If it does not relate to the original issue of this post, you can file a separate one for us to review.

Thank you

kbarlett001 commented 9 months ago

I am using extension version 0.5.1 and am still seeing this issue or what appears to be the same issue. Thank you. image

image

davehouser1 commented 9 months ago

I found a workaround for this. The problem is ADS knows knows how to process basic encodings like integer (number,int,bigint,etc.) or string (varchar,etc.), there maybe more but I don't know what they are (maybe date and time?).

Encodings like CIDR causes problems. I can only assume your ip_address is an encoding that is not a varcahr. I am guessing there wasn't any logic put in place for ADS to process Postgres CIDR encodings.

You can add ::TEXT at the end of each attribute you are querying with an encoding type that ADS does not recognize (i.e. CIDR). Doing this will force ADS to convert the encoding to a string before presenting. From your example I would do the following.

select asset_id
,mac_address
,ip_address::TEXT
from public.dim_asset

Can you confirm if this helped? I bet you could do the same for other encoding types that ADS does not understand.

I would recommend ADS put this in their documentation because it is not obvious. More so, I'd like to recommend ADS do this conversion for us so we don't have to. This application presents data, so obviously we want any weird encodings to be converted to strings for presentation.

francesconi commented 8 months ago

Any ETA on this?

nasc17 commented 8 months ago

image

DaeunYim commented 7 months ago

I found a workaround for this. The problem is ADS knows knows how to process basic encodings like integer (number,int,bigint,etc.) or string (varchar,etc.), there maybe more but I don't know what they are (maybe date and time?).

Encodings like CIDR causes problems. I can only assume your ip_address is an encoding that is not a varcahr. I am guessing there wasn't any logic put in place for ADS to process Postgres CIDR encodings.

You can add ::TEXT at the end of each attribute you are querying with an encoding type that ADS does not recognize (i.e. CIDR). Doing this will force ADS to convert the encoding to a string before presenting. From your example I would do the following.

select asset_id
,mac_address
,ip_address::TEXT
from public.dim_asset

Can you confirm if this helped? I bet you could do the same for other encoding types that ADS does not understand.

I would recommend ADS put this in their documentation because it is not obvious. More so, I'd like to recommend ADS do this conversion for us so we don't have to. This application presents data, so obviously we want any weird encodings to be converted to strings for presentation.

Could you please also add what datatypes were you using in this table? I suspect this is due to macaddr8 array type?

I tested with this dummy table. CREATE TABLE network_data_extensive ( id SERIAL PRIMARY KEY, ip_address inet, ip_address_array inet[], subnet cidr, subnet_array cidr[], mac_address_standard macaddr, mac_address_extended macaddr8, mac_address_standard_array macaddr[], mac_address_extended_array macaddr8[] );

Running query on this table works with the existing version except for macaddr8[] datatype. I'll add macaddr8[] in the upcoming PR.

davehouser1 commented 7 months ago

@DaeunYim

Could you please also add what datatypes were you using in this table?

I already did in my post, see above

Encodings like CIDR causes problems. I can only assume your ip_address is an encoding that is not a varcahr. I am guessing there wasn't any logic put in place for ADS to process Postgres CIDR encodings.

Datatypes are cidr.

I dont use macaddr or macaddr8.

DaeunYim commented 7 months ago

@DaeunYim

Could you please also add what datatypes were you using in this table?

I already did in my post, see above

Encodings like CIDR causes problems. I can only assume your ip_address is an encoding that is not a varcahr. I am guessing there wasn't any logic put in place for ADS to process Postgres CIDR encodings.

Datatypes are cidr.

I dont use macaddr or macaddr8.

Hi, I don't see any issue with CIDR data type. Can you update the extension if there's any newer version?

I tested out these different ip address values in the above column. I'll try to check what I can possibly have missed.

'192.168.1.1' '192.168.1.1/24' '2001:db8::1234 '2001:db8::1234/64'

davehouser1 commented 7 months ago

Hi, I don't see any issue with CIDR data type. Can you update the extension if there's any newer version?

I don't know what this means, what do you mean by "update the extension", do you mean update the whole ADS program?

ps2goat commented 7 months ago

Postgres support in ADS uses the postgres extension. On the side bar is an icon with four squares; when that is active (click it), you should see the list of installed extensions, which should include postgres. Clicking the postgres extension should either bring you to the screen to update or, in my case, tells me a reload is required to enable the new update (I must have auto update enabled).

jcosmo commented 4 months ago

Still occurring on the latest Mac silicon build of ADS and the latest postgres plugin.

image image

Also get weird rendering problems in the sidebar for the list of databases:

image