Removing Final Element in YAML Array Inconsistent Behaviour

Steps to reproduce

Have YAML like so:

---
tags:
  - testing
aliases:
  - testing
---

Then via the UI properties editor, delete either tag or alias, and you’ll see it change to tags: [] or aliases: []

---
tags:
  - testing
aliases: []
---

Interacting then with the Properties UI alters the last appended empty array and removes the brackets, then again after another interaction.

---
tags: []
aliases: 
---

Aug-10-2024 11-28-45

Did you follow the troubleshooting guide? Y

Expected result

It should simply remove the tag or alias and leave the area after the colon empty, returning tags: or aliases:

Actual result

Returns tags: [] or aliases: [] on final deletion

Environment

SYSTEM INFO:
Obsidian version: v1.6.5
Installer version: v1.6.3
Operating system: Darwin Kernel Version 24.0.0: Wed Jul 31 21:50:55 PDT 2024; root:xnu-11215.0.199.501.2~1/RELEASE_ARM64_T6020 24.0.0
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: on

RECOMMENDATIONS:
none

Please try to search before posting

You see, I did actually find that, and if you considered my bug in seldom , it’s completely different. That topic is suggesting lists should stay as bar: [], whereas my issue, which is completely different, asks why it changes on interaction from that empty array to a null value?

Sure, the value may still be an array, but say I delete the last element, and don’t interact with the Properties UI, then it’s stuck as tags: [] until I interact again. This is seemingly a bug.

Semantics aside, why is it inconsistent? What is the technical reason for this?

Please reinstate as a bug. This is different to the linked bug—which is in the graveyard and not to be fixed anyway.

The technical reason is that we process the YAML section internally (serialize, process, and deserialize it). You should not have the expectation that YAML stays the way you write it.

This is not related to the way I write it—you’ll notice it is entirely altered through the Properties UI.

Given your information, I consider this a bug within the processing process. It should go instantly to a null value—rather than first to an empty array, and then to a null value on subsequent interaction. I do not expect it to stay the way I write it. I do however, expect the behaviour to be consistent.

Why should it go go to an empty array and then a null value? It’s almost like it’s processing empty values at the wrong step in the interaction process.

As explained in the thread linked above, internally there is no difference between the two. There are no negative consequences with either format.

Feel free to open a feature request if you feel strongly there should be only one format.

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