realm / realm-studio

Realm Studio
https://realm.io/products/realm-studio/
Apache License 2.0
293 stars 40 forks source link

Exception while trying to access objects with RealmUUID property (Sentry ID: f5a9ed08e6334fbbb47c3e70320db3fa) #1649

Open RationalRank opened 1 month ago

RationalRank commented 1 month ago

Describe the bug Receiving this error BSONTypeError: UUID string representations must be a 32 or 36 character hex string in multiple scenarios

  1. While trying to double click on embedded objects and looking up (Screenshot 1)
  2. In a column (Screenshot 2)
  3. While trying to a view a RealmObject (Screenshot 3)

Few things to note:

  1. This specific realm file was migrated from v23 to v24 as a result of upgrading the kotlin SDK from v1.10.2 to v1.15.0
  2. Most of these document's RealmUUID's are constructed using an UUID from our APIs

To Reproduce Steps to reproduce the behavior:

  1. Open any existing realm file
  2. Double click on embedded object
  3. See error

Expected behavior

Screenshots

image image image

Versions:

Additional context Stacktrace:

BSONTypeError: UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
    at new BSONTypeError (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/bson/lib/error.js:41:28)
    at uuidHexStringToBuffer (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/bson/lib/uuid_utils.js:14:15)
    at new UUID (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/bson/lib/binary.js:290:60)
    at Obj.getAny (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/realm/binding/generated/native.node.cjs:373:12)
    at /Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/realm/dist/PropertyHelpers.js:30:32
    at Proxy.get (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/realm/dist/ClassMap.js:59:28)
    at K (file:///Applications/Realm%20Studio.app/Contents/Resources/app.asar/build/realm-browser.renderer.bundle.js:1:346064)
    at vt.render (file:///Applications/Realm%20Studio.app/Contents/Resources/app.asar/build/realm-browser.renderer.bundle.js:1:434066)
    at finishClassComponent (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:17160:31)
    at updateClassComponent (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:17110:24)
    at beginWork (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:18620:16)
    at HTMLUnknownElement.callCallback (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:188:14)
    at HTMLUnknownElement.sentryWrapped (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/@sentry/browser/cjs/helpers.js:93:17)
    at Object.invokeGuardedCallbackDev (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:237:16)
    at invokeGuardedCallback (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:292:31)
    at beginWork$1 (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:23203:7)
    at performUnitOfWork (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:22157:12)
    at workLoopSync (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:22130:22)
    at performSyncWorkOnRoot (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:21756:9)
    at /Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:11089:24
    at unstable_runWithPriority (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/scheduler/cjs/scheduler.development.js:653:12)
    at runWithPriority$1 (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:11039:10)
    at flushSyncCallbackQueueImpl (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:11084:7)
    at flushSyncCallbackQueue (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:11072:3)
    at scheduleUpdateOnFiber (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:21199:9)
    at Object.enqueueSetState (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react-dom/cjs/react-dom.development.js:12639:5)
    at Component.setState (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/react/cjs/react.development.js:471:16)
    at vt.changeFocusIfAllowed (file:///Applications/Realm%20Studio.app/Contents/Resources/app.asar/build/realm-browser.renderer.bundle.js:1:439309)
    at Object.onListFocussed (file:///Applications/Realm%20Studio.app/Contents/Resources/app.asar/build/realm-browser.renderer.bundle.js:1:429901)
    at Ln.onCellSingleClick (file:///Applications/Realm%20Studio.app/Contents/Resources/app.asar/build/realm-browser.renderer.bundle.js:1:392363)
    at file:///Applications/Realm%20Studio.app/Contents/Resources/app.asar/build/realm-browser.renderer.bundle.js:1:392016
    at sentryWrapped (/Applications/Realm Studio.app/Contents/Resources/app.asar/node_modules/@sentry/browser/cjs/helpers.js:93:17)
    in vt (created by W)
    in W
    in q
    in Unknown
sync-by-unito[bot] commented 1 month ago

➤ PM Bot commented:

Jira ticket: RSTUDIO-536

kneth commented 1 month ago

I haven't been able to reproduce it.

To generate a Realm file with UUID and embedded objects, I have used the following script:

const Realm = require("realm");
const BSON = require("bson");
const Parent = {
  name: "Parent",
  primaryKey: "key",
  properties: {
    key: "uuid",
    child: "Child",
  },
};
const Child = {
  name: "Child",
  embedded: true,
  properties: {
    key: "uuid",
    value: "string",
  },
};

let realm = new Realm({ schema: [Parent, Child] });
realm.write(() => {
  realm.create("Parent", { key: new BSON.UUID(), child: { key: new BSON.UUID(), value: "hello world" } } );
});
realm.close();

File was created using Realm JS v12.6.0. I can open the file with Realm Studio v15.0.1 (prompts me to upgrade), and I can access the embedded object.

Can you share either a Realm file or sample Kotlin code to reproduce it?

github-actions[bot] commented 2 weeks ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

RationalRank commented 1 week ago

I haven't been able to reproduce it.

To generate a Realm file with UUID and embedded objects, I have used the following script:

const Realm = require("realm");
const BSON = require("bson");
const Parent = {
  name: "Parent",
  primaryKey: "key",
  properties: {
    key: "uuid",
    child: "Child",
  },
};
const Child = {
  name: "Child",
  embedded: true,
  properties: {
    key: "uuid",
    value: "string",
  },
};

let realm = new Realm({ schema: [Parent, Child] });
realm.write(() => {
  realm.create("Parent", { key: new BSON.UUID(), child: { key: new BSON.UUID(), value: "hello world" } } );
});
realm.close();

File was created using Realm JS v12.6.0. I can open the file with Realm Studio v15.0.1 (prompts me to upgrade), and I can access the embedded object.

Can you share either a Realm file or sample Kotlin code to reproduce it?

Hi @kneth . Thanks for getting back on this and apologies for the delayed response

I was able to create a minimal reproducible sample. This happens specifically for UUID v1.

We do not generate UUID v1 now on our API, but some of the old data in our system were generated using UUID v1. I don't see this error for the latest data in the system that has unique IDs generated using UUID v4

You can find the reproducible sample on Github here and the realm file here

image

jmacindoe commented 1 week ago

I'm seeing this issue with UUIDv7. My object is not embedded. For me the bug also only started occuring after migrating from v23 to v24. So possibly it happens for all UUIDv1 and UUIDv7 ids on v24.

Here's the basics of my code, in Kotlin

class MyEntity() : RealmObject {
    @PrimaryKey
    var _id: RealmUUID = RealmUUID.random()
}
import kotlinx.uuid.UUIDv7

val uuid = UUIDv7(millis)
this._id = RealmUUID.from(uuid.encodeToByteArray())