remko / dsadmin

Google Cloud Datastore Emulator Administration UI
MIT License
62 stars 6 forks source link

DSAdmin crashes when changing namespace from default #8

Closed FredrikAugust closed 1 year ago

FredrikAugust commented 1 year ago

Hi! Thanks for making this killer application.

We're trying to use it with the datastore emulator at my company, but we're running into a problem when switching namespaces. The entire application simply crashes.

Let me know what information you need to debug this and I'll happily provide:)

Screenshot 2023-08-01 at 10 43 31
remko commented 1 year ago

@FredrikAugust I tried it against my test setup with namespaces, but I can't reproduce it yet.

Do you do anything else before switching namespaces?

Can you start a development server (see the README for instructions; you'll want to run it against your own datastore server) and make it crash; this should give more useful backtraces.

remko commented 1 year ago

If I'm not mistaken, the crash is happening in encodeKey, called from the EntitiesTable. This seems to mean that the key doesn't have a partitionId, which is strange (as far as I understand, partitionId is required; i would especially expect it to be there if you have a namespace).

What could help is that you add extra logging in encodeKey to see what the key actually contains (to double check that it actually is a key, but somehow incomplete, or something else).

FredrikAugust commented 1 year ago

Hi, thanks for the quick response! I'll try it right away and report back.

FredrikAugust commented 1 year ago

Do you do anything else before switching namespaces?

Nope! If it's of any interest, we're running the datastore emulator through a docker image:

  datastore:
    image: google/cloud-sdk:latest
    ports:
      - 8432:8432
    command: |
      gcloud beta emulators datastore start --host-port=0.0.0.0:8432 --use-firestore-in-datastore-mode --project=***

I've started the dev server, and reproduced the crash. The errors I get in the console are the following (I stripped away stack traces from React core):

Uncaught Error: Duplicate columns were found with ids: "key" in the columns array above
    at useTable3 (useTable.js:262:13)
    at Table (Table.tsx:60:7)
The above error occurred in the <Table> component:
    at Table (http://localhost:64645/dist/index.js:40562:5)
    at EntitiesTable (http://localhost:64645/dist/index.js:40758:5)
    at KindTable (http://localhost:64645/dist/index.js:45780:5)
    at div
    at KindPage (http://localhost:64645/dist/index.js:45843:5)
    at Route (http://localhost:64645/dist/index.js:39912:18)
    at Switch (http://localhost:64645/dist/index.js:39943:19)
    at div
    at DatastoreAdminView (http://localhost:64645/dist/index.js:46466:33)
    at Router (http://localhost:64645/dist/index.js:39905:42)
    at APIProvider (http://localhost:64645/dist/index.js:39518:5)
    at QueryClientProvider3 (http://localhost:64645/dist/index.js:23220:27)
    at DatastoreAdmin (http://localhost:64645/dist/index.js:46584:29)
Uncaught Error: Duplicate columns were found with ids: "key" in the columns array above
    at useTable3 (useTable.js:262:13)
    at Table (Table.tsx:60:7)

When browsing the "main page" the key values are:

{
    "partitionId": {
        "projectId": "xxx"
    },
    "path": [
        {
            "kind": "xxx:namespace",
            "name": "xxx"
        }
    ]
}

and the "encoded key" value is:

[
    "xxx",
    "",
    [
        [
            "xxx:namespace",
            "xxx"
        ]
    ]
]
remko commented 1 year ago

Am I right that you have an entity that has key as a property name?

I was able to reproduce a crash in that situation. I'll fix that.

remko commented 1 year ago

@FredrikAugust Can you try again with the latest commit?

FredrikAugust commented 1 year ago

Am I right that you have an entity that has key as a property name?

I was able to reproduce a crash in that situation. I'll fix that.

@emmahorn could you confirm or deny this?

FredrikAugust commented 1 year ago

@remko Works like a charm with latest commit (ccd3ebc5d18028c66aa5d8c86fb388d2299a0bb8)!

EmmaHorn commented 1 year ago

Am I right that you have an entity that has key as a property name?

I was able to reproduce a crash in that situation. I'll fix that.

Yes, we do have an entity with key as a property name.

Thank you for fixing this so quickly!

remko commented 1 year ago

Great!

I published a new version with the fix (v0.18.2)