Canvas file corruption if file node has custom property of type object or list

Steps to reproduce

This is a bug report regarding the support for custom properties inside .canvas files. A file node with a custom property of type object or list will cause a corrupted canvas file due to a trailing comma in the resulting JSON. If you try to open it again, the error <Failed to open “”>

Here is some more context with an MRE: [BUG] Unable To Open if Plugin Is Disabled and Canvas Interacted With · Issue #82 · Developer-Mike/obsidian-advanced-canvas · GitHub

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

Yes. This issue persists.

Expected result

Not a corrupted file :sweat_smile:.

Actual result

As stated above, the save file will contain a trailing comma, corrupting the whole file.

Environment

SYSTEM INFO:
Obsidian version: v1.6.5
Installer version: v1.5.3
Operating system: Windows 10 Pro 10.0.22631
Login status: not logged in
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 4
Plugins enabled: 0

RECOMMENDATIONS:
none


Additional information

I really think this is a critical bug. Proper support for custom properties is crucial to enable third-party plugins to improve the canvas experience.

5 Likes

I have suggested to Mike on Discord to add simple reproduction steps on this, and would suggest attaching the simplest possible .canvas file that contains the problem.

1 Like

Yes, thank you ClareMacrae for your suggestions for improvement.

Steps To Reproduce

  1. Create a new canvas and add a file node
  2. Open the canvas file inside a text editor
  3. Add a custom property with a value type of object ({}) or list ([]) inside the file node data object (In the following example, I’ve added the field customProperty)
  4. Open the file inside Obsidian
  5. Modify the file and save it
  6. Try to reopen the file inside Obsidian → The following error notice shows up

Error Popup

Error

Reason Of The Error

The canvas core plugin uses a custom JSON stringify function. This function is the culprit of this behavior. If a file node contains a property that is of type object or list, it adds a trailing comma to the last key-value pair of the file node data. This causes a read error when reopening it.

Example File

(No .canvas file upload is allowed, so I just share a zip here)
Saving Error.zip (495 Bytes)

Importance

While this issue doesn’t affect the core canvas plugin (yet), the support for custom properties is crucial for any canvas-enhancing plugin. Additionally, a broken JSON stringify function is a ticking time bomb that must be fixed sooner or later (I wish sooner :wink:).

1 Like

This needs to be fixed very very soon, I’ve already lost a lot of progress on some canvases due to this bug. Honestly they need to add more features and updates to canvas in general, it’s very limited with what you can do with it, we wouldn’t have to deal with this bug in the first place if canvas received more updates. Heptabase has so much quality of life features with their canvas I’m surprised Obsidian hasn’t caught up in the slightest.

1 Like

Thanks, we’ll check this.

Will be fixed in Obsidian v1.7. No ETA

4 Likes

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