Azure / azure-cosmosdb-ads-extension

Azure Data Studio extension for Azure CosmosDB
MIT License
16 stars 10 forks source link

Error : Cannot read properties of undefined (reading 'documents') #112

Closed JoeFieck closed 5 months ago

JoeFieck commented 7 months ago

Hello. I had opened https://github.com/microsoft/azuredatastudio/issues/25522 and was instructed to open here for support.

Upgrade ADS to 1.48.0 Install the Azure Cosmos DB extension. Make a connection to Azure Cosmos DB using a connection string. Notice that the UI correctly shows the same list of containers showing from Data Explore from withing Azure directly.

Open a query and run: select * from c

You may see a message saying: Cannot read properties of undefined (reading 'documents')

No data is returned.

What is interesting is that on the bug fix list for 1.48 it shows having fixed an issue with : Connections Fixed Error: “Cannot read properties of undefined (reading 'serverInfo')”

This message here is the same except for it shows 'serverInfo' where mine shows 'documents'

----------------Here are the system info and package info you may want--------------- Item Value CPUs 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz (8 x 2419) GPU Status 2d_canvas: enabled canvas_oop_rasterization: enabled_on 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) 15.73GB (6.34GB free) Process Argv
Screen Reader no VM 0% Extensions (9) Extension Author (truncated) Version admin-pack Mic 0.0.2 admin-tool-ext-win Mic 0.1.3 agent Mic 0.49.0 azure-cosmosdb-ads-extension Mic 0.4.2 azuredatastudio-postgresql Mic 0.6.0 dacpac Mic 1.14.0 import Mic 1.6.1 net-6-runtime Mic 1.1.0 profiler Mic 0.14.0

JoeFieck commented 7 months ago

image

JoeFieck commented 7 months ago

image

JoeFieck commented 7 months ago

Hello all. I just upgrade ADS to 1.48.0 and installed the azure-cosmosdb-ads-extention at 0.4.2. When I try to run a query I get this "Cannot read properties of undefined (reading 'documents')" error.
When I launch ADS and connect to my Cosmos db on Azure it will load up the databases and the containers but just will not let me run the basic select statement.

I have seen many others out there seeing the same but everyone's solution is different and usually ends with this going away on its own or needing a reinstallation of the extension. I have tried that but no luck so far.

What is interesting is there was a bug fixed on ADS Cosmo DB ads ext that fixed an error with: Error: “Cannot read properties of undefined (reading 'serverInfo')” . So only diff is it was "serverInfo" where mine is "documents". I'm sure they are related. Please help. I really need one place to work and ADS is where all my other SQL connections are made.

JoeFieck commented 7 months ago

Hi @cheenamalhotra . I have opened this as you requested...

JoeFieck commented 7 months ago

Hi @cheenamalhotra , can we have this assigned and looked at please...

cheenamalhotra commented 7 months ago

I don't work on the extension team, tagging @languy to help triage and investigate the issue.

JoeFieck commented 7 months ago

Thanks Cheena.

On Wed, Apr 3, 2024 at 2:44 PM Cheena Malhotra @.***> wrote:

I don't work on the extension team, tagging @languy https://github.com/languy to help triage and investigate the issue.

— Reply to this email directly, view it on GitHub https://github.com/Azure/azure-cosmosdb-ads-extension/issues/112#issuecomment-2033577143, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLTBBJRVG7XSHJFWA64FUDY3OJLXAVCNFSM6AAAAABFRFJMBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZTGU3TOMJUGM . You are receiving this because you authored the thread.Message ID: @.***>

JoeFieck commented 7 months ago

Hello @languy . Had anyone had a minute to look into fixing this on the next release of Azure Data Studio. Again there was a very similar message fixed on .48 that I think is the same here..

JoeFieck commented 6 months ago

@languy and @cheenamalhotra can someone acknowledge any of these is even been seen. Its so frustrating trying to get something addressed over the internet these days. You just feel like things go into the black hole and never reach a humans ears. :-|

Again I think this is regression to a bug fixed on version 49. Can someone look into this or at least tell me we're going to so I don't keep coming back here trying to reach anyone that might have access to investigate... I would really appreciate it.

JoeFieck commented 6 months ago

@languy and @cheenamalhotra can someone acknowledge any of this is even being seen. Its so frustrating trying to get something addressed over the internet these days. You just feel like things go into the black hole and never reach a humans ears. :-|

Again I think this is regression to a bug fixed on version 49. Can someone look into this or at least tell me we're going to so I don't keep coming back here trying to reach anyone that might have access to investigate... I would really appreciate it.

JoeFieck commented 6 months ago

Hello there @languy and @cheenamalhotra . Just following up on this one again. Any update?

JoeFieck commented 6 months ago

Hi Cheena. I have opened the new case with the cosmos connector team.

Description and number is: Error : Cannot read properties of undefined (reading 'documents') #112

I have been updating for status tagging you and languy but have not heard anything or seen any updates. Checking again...

On Fri, Apr 5, 2024 at 4:51 PM Joe Fieck @.***> wrote:

Thanks Cheena.

On Wed, Apr 3, 2024 at 2:44 PM Cheena Malhotra @.***> wrote:

I don't work on the extension team, tagging @languy https://github.com/languy to help triage and investigate the issue.

— Reply to this email directly, view it on GitHub https://github.com/Azure/azure-cosmosdb-ads-extension/issues/112#issuecomment-2033577143, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLTBBJRVG7XSHJFWA64FUDY3OJLXAVCNFSM6AAAAABFRFJMBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZTGU3TOMJUGM . You are receiving this because you authored the thread.Message ID: @.***>

JoeFieck commented 6 months ago

Hi @languy just following up on this again...

languy commented 6 months ago

Hi @JoeFieck, apologies for the delayed response (I was out of office).

The bug is definitely in this extension, not in the ADS 1.48 code. I see some places where this error could happen, let's narrow it down:

JoeFieck commented 6 months ago

Hello @languy . The steps I follow are to open ADS then right click the db and select "Open Query". Then I run the "select * from c" query. The first time I hit run nothing happens but if I hit run a 2nd time I see the dialog below which I have expanded...

image

JoeFieck commented 6 months ago

Here is the console output you wanted reproducing the error:

onSubmitQuery
console.ts:137 [Extension Host] onDidReceiveMessage
console.ts:137 [Extension Host] submitquery
notificationsAlerts.ts:42 Cannot read properties of undefined (reading 'documents')
  | onDidChangeNotification | @ | notificationsAlerts.ts:42 -- | -- | -- | --   | (anonymous) | @ | notificationsAlerts.ts:28   | _deliver | @ | event.ts:1109   | _deliverQueue | @ | event.ts:1120   | fire | @ | event.ts:1144   | addNotification | @ | notifications.ts:204   | notify | @ | notificationService.ts:175   | (anonymous) | @ | mainThreadMessageService.ts:88   | ZoneAwarePromise | @ | C:\Program Files\Azu…s\dist\zone.js:1351   | _showMessage | @ | mainThreadMessageService.ts:44   | $showMessage | @ | mainThreadMessageService.ts:38   | _doInvokeHandler | @ | rpcProtocol.ts:457   | _invokeHandler | @ | rpcProtocol.ts:442   | _receiveRequest | @ | rpcProtocol.ts:370   | _receiveOneMessage | @ | rpcProtocol.ts:296   | (anonymous) | @ | rpcProtocol.ts:161   | _deliver | @ | event.ts:1109   | fire | @ | event.ts:1140   | fire | @ | ipc.net.ts:650   | J.onmessage | @ | localProcessExtensionHost.ts:586
JoeFieck commented 6 months ago

@languy Here is the console output in a screen shot if this helps interpret with the format at all...

image

JoeFieck commented 6 months ago

Here is the screen shot show that from Azure Portal we get the records...

image

JoeFieck commented 6 months ago

Also @languy I'm not sure this helps but here is the notificationsAlert.ts typescript file throwing the error...

/*---------------------------------------------------------------------------------------------

import { alert } from 'vs/base/browser/ui/aria/aria'; import { localize } from 'vs/nls'; import { INotificationViewItem, INotificationsModel, NotificationChangeType, INotificationChangeEvent, NotificationViewItemContentChangeKind } from 'vs/workbench/common/notifications'; import { Disposable } from 'vs/base/common/lifecycle'; import { toErrorMessage } from 'vs/base/common/errorMessage'; import { NotificationPriority, Severity } from 'vs/platform/notification/common/notification'; import { Event } from 'vs/base/common/event';

export class NotificationsAlerts extends Disposable {

constructor(private readonly model: INotificationsModel) {
    super();

    // Alert initial notifications if any
    for (const notification of model.notifications) {
        this.triggerAriaAlert(notification);
    }

    this.registerListeners();
}

private registerListeners(): void {
    this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
}

private onDidChangeNotification(e: INotificationChangeEvent): void {
    if (e.kind === NotificationChangeType.ADD) {

        // ARIA alert for screen readers
        this.triggerAriaAlert(e.item);

        // Always log errors to console with full details
        if (e.item.severity === Severity.Error) {
            if (e.item.message.original instanceof Error) {
                console.error(e.item.message.original);
            } else {
                console.error(toErrorMessage(e.item.message.linkedText.toString(), true));
            }
        }
    }
}

private triggerAriaAlert(notification: INotificationViewItem): void {
    if (notification.priority === NotificationPriority.SILENT) {
        return;
    }

    // Trigger the alert again whenever the message changes
    const listener = notification.onDidChangeContent(e => {
        if (e.kind === NotificationViewItemContentChangeKind.MESSAGE) {
            this.doTriggerAriaAlert(notification);
        }
    });

    Event.once(notification.onDidClose)(() => listener.dispose());

    this.doTriggerAriaAlert(notification);
}

private doTriggerAriaAlert(notification: INotificationViewItem): void {
    let alertText: string;
    if (notification.severity === Severity.Error) {
        alertText = localize('alertErrorMessage', "Error: {0}", notification.message.linkedText.toString());
    } else if (notification.severity === Severity.Warning) {
        alertText = localize('alertWarningMessage', "Warning: {0}", notification.message.linkedText.toString());
    } else {
        alertText = localize('alertInfoMessage', "Info: {0}", notification.message.linkedText.toString());
    }

    alert(alertText);
}

}

languy commented 6 months ago

Thanks for the detailed information. Unfortunately, it looks like the stack trace shows the code that displays the error message in ADS (NotificationsAlerts), not the code that actually triggered the exception in the extension.

This said, your log provides a few clues: the last successful console log is "submitquery" and the error message shows that it's trying to read the documents property of an undefined object. This is one place where it could happen, but my guess is it's happening inside this call which also reads the documents property of the result. The result of a query should always be an object (maybe an empty array if no results), but never undefined. Why would the proxy return an undefined query result, then? The query is executed by a binary proxy implemented in C# which is hard to debug in your production build. One possible reason: you have multiple proxies running at the same time against the same database which yields undefined result. That seems consistent with what you reported: maybe the 2nd time you pressed, it spawned another proxy while the proxy from the first click was still executing.

Let's try this:

If that does not resolve the issue, we may have to understand why the query is failing or hanging. This is where the query is executed using the C# SDK.

JoeFieck commented 6 months ago

Hello @languy . Here are my responses to your requests and suggestions...

I was using the 0.4.3 extension already but I went ahead and uninstalled and installed it new again just for good measure. I rebooted and restarted ADS. I then opened a query window and ran the "select * from c" query just once... I do not see any type of progress bar on it that ever needed to finish. I let the first run sit for like 20 minutes but nothing ever returned. Here is how the screen looked:

image

JoeFieck commented 6 months ago

To your suggestion about running "select count(1)" from ADS extension. I did try that and the results are the same. I can run it once and nothing happens then I run it again after some time and I get this message saying :

image

JoeFieck commented 6 months ago

Were you ever able to run the query on other databases in your Cosmos DB account or other Cosmos DB account databases? Me : No. I tried on two seperate Cosmos servers with the same behavior. Seems isolated to the extension I think.

How long does the query take on the portal Data Explorer? (it might slower on your desktop?) Me: From Azure Data Explorer the query runs pretty fast. I'd say maybe 2 seconds.

Is there any special configuration that might affect accessing the data? If so, can you repro on a test account with the default setup? Me: I have been able to reproduce this on two separate instances of Cosmo from here.

Try a query that doesn't access the data? Such as SELECT count(1) Me: I tried and got same results. Nothing back then run again and get error.

Can you confirm you are on Windows? Me. Yes I'm on Windows.

Just a comment here. As these things go our back and forth exchanges here on github are heavily paced by our time zone differences. We'd probably triple our productivity if we coordinated a time when we could do a web meeting and share my screen. I may even then be able to try connecting to a test Cognos server there on your side remotely from here and see if we can trigger the error

languy commented 6 months ago

I may even then be able to try connecting to a test Cognos server there on your side remotely from here and see if we can trigger the error

Yes, please go in the portal and open your cosmos db account. Under "Support + Troubleshooting" (the last tab on the left), please file a ticket, so we can contact you directly. Thanks.

JoeFieck commented 6 months ago

@languy It not letting me create the ticket. It just keeps taking me around in circles but never shows me any "create ticket" or anything like that. I'm here...

image

JoeFieck commented 6 months ago

I am fairly sure this is checking for problems on the instance of Cosmos running on Azure not for any issues from a remote client. I think that could be why its not finding anything wrong and offering me a button to create a ticket. Maybe anyway...

JoeFieck commented 6 months ago

Actually @languy its telling me this...

image

We have another plan under Xen.ai account that is paid. But I can't login to that one here. Is this going to be possible to continue without an incident?

JoeFieck commented 6 months ago

Don't give up on me @languy :-) . If you google this error there are a ton of people in the user community seeing this issue. None ever having gotten to any real fix. Maybe you could create the ticket for me and we could further our communications here on Github as this seems to reach us both okay for now. What do you think?

languy commented 6 months ago

@joefieck Can you please fill out this form? and we will contact you directly. Thanks.

JoeFieck commented 6 months ago

Hi @languy . I have filled out the form. This was how the confirmation screen looked after I hit Submit. No case or anything...

image

jbriggs22 commented 6 months ago

I was experiencing this issue after switching to MacBook and I had given up based on seeing this thread. Then later this week I installed the dotnet Runtime and SDK (dotnet 8 and dotnet 6) and had added it to PATH. Then tried the cosmosDb extension again and now it has been working fine since.

Looking at the source code for this extension, I see it's using dotnet for the CosmosDbProxy. Is it possible that missing dotnet (or not finding it on the PATH) is the cause?

Also, to note that I did have the .NET 6 Runtime Azure Data Studio Extension installed prior to installing the SDKs. But I don't think I was able to run just the dotnet command in a terminal.

Hope this helps.

JoeFieck commented 6 months ago

Hi @jbriggs22 . From my talks with @languy we think this is related to the dotnet sdk used by ADT. What is odd is that ADS is able to find all the containers and databases then show them in the object browser. Just that on my P.C. using ADS it can't run a query. Even a query that doesn't try to access a container. I would think for my client to know to show me all three containers in the object browser it would still need dotnet connector. If so its very peculiar that it would work there then fail when running a query.

From the thread here I did install the Azure Cosmos DB extension into VS Code and from there I can run queries. VS Code uses the JavaScript SDK and that works fine.

JoeFieck commented 6 months ago

Well @jbriggs22 I think you were right. I installed a tool called Cosmos DB Explorer on Windows and it made me install a new dotnet driver. After doing so the my connection to Cosmos in ADP started working. Was the dotnet driver as you said. Closing thread now. And thanks!

JoeFieck commented 6 months ago

Hello all. We can shut down this case. I installed Windows based Cosmos DB Explorer and it made me install a new dotnet driver which magically got the Cosmos extension in ADP working again. Thanks for the help...

On Sat, Apr 20, 2024 at 4:58 AM Joel Briggs @.***> wrote:

I was experiencing this issue after switching to MacBook and I had given up based on seeing this thread. Then later this week I installed the dotnet Runtime and SDK (dotnet 8 and dotnet 6) and had added it to PATH. Then tried the cosmosDb extension again and now it has been working fine since.

Looking at the source code for this extension, I see it's using dotnet for the CosmosDbProxy. Is it possible that missing dotnet (or not finding it on the PATH) is the cause?

Also, to note that I did have the .NET 6 Runtime Azure Data Studio Extension installed prior to installing the SDKs. But I don't think I was able to run just the dotnet command in a terminal.

Hope this helps.

— Reply to this email directly, view it on GitHub https://github.com/Azure/azure-cosmosdb-ads-extension/issues/112#issuecomment-2067205576, or unsubscribe https://github.com/notifications/unsubscribe-auth/BDLTBBIC6B562B3VG5OAWM3Y6FZPTAVCNFSM6AAAAABFRFJMBKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRXGIYDKNJXGY . You are receiving this because you were mentioned.Message ID: @.***>

fa-bwilliams commented 6 months ago

I am experiencing this exact issue today. I am using MacOS. I have version.1.48.0 of ADS and v0.4.3 for Cosmos DB extension. I do not know why you would suggest shutting down the case. It works properly for me too if using the DB Explorer via Azure Portal. However, it is still broken in ADS.

JoeFieck commented 6 months ago

Hi @fa-bwilliams . This thread got mixed up with a side one that I was addressing with @languy offline via e-mail. By "shut down the case" I was saying we could discontinue the e-mail threads. Not that we should forget about this. It is a bug, they have identified the fix and to the best of my knowledge are working on it. And just heads up, VS Codes Cosmos extension works. I also installed one called "Cosmos DB Explorer" that has the features of Azures "Data Explorer". Both worked if you need something to use until ADS extension fix is out.

languy commented 6 months ago

Hi all, there is a bug in the way the extension spawns the proxy (a separate executable that actually executes the query). It does not correctly use the .NET extension and fails to spawn the proxy. The workaround is to manually install the .NET runtime or sdk (or install an app that itself installs the runtime). Sorry for the inconvenience.

languy commented 5 months ago

The fix for this issue has just been released in v0.4.4.