ID value changes between source mode and live preview

Steps to reproduce

  1. Create a new note
  2. Add an ‘id’ property field
  3. Enter source mode
  4. Enter the value 751480158363451392
  5. Switch out of source mode

Did you follow the troubleshooting guide? [Y/N]

Yes.

Expected result

I expect to see the same value (ending in 392)

Actual result

I see the last 3 digits change to 400.

Environment

Running on Linux right now but also verified on iOS.
SYSTEM INFO:
Obsidian version: v1.8.4
Installer version: v1.7.7
Operating system: #49-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 4 02:06:24 UTC 2024 6.8.0-49-generic
Login status: logged in
Language: en
Catalyst license: none
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information


1 Like

Weird. Seems to work if stored as Text rather than Number:

Is this something you are doing, or is this a built-in property that Obsidian is generating via some command or convention? I assume this is your own property, and you’ve set it to type “Number”, correct?

I think you’re just reaching the maximum length of an integer in (Javascript I assume?) Obsidian. And so it’s rounding it off. It’s likely storing it in a bit-depth that you are exceeding.

It makes sense that storing it as a string would allow you to have any arbitrary length. If this is your own convention for storing unique ID numbers, I suggest you use strings. Unless you have a reason to compare the numerical value (greater than or less than, etc.)

Also, I don’t believe this has anything to do with Source Mode. You’ll see the same result if you reload or restart Obsidian. Or close and reopen the note.

1 Like

Testing this out further. I looked up the biggest int in Javascript Number.MAX_SAFE_INTEGER - JavaScript | MDN

9007199254740991

And yes if I enter 9007199254740992 it works. If I enter 9007199254740993 it rounds back down to 9007199254740992

So I’m going to move this from bugs. This isn’t a bug. You’ve just a hit a limitation of integers in Javascript, and will have to work around it with fewer digits, or strings.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.