Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Templater Clobbering Existing Notes #1269

Open
acook opened this issue Dec 17, 2023 · 2 comments
Open

Templater Clobbering Existing Notes #1269

acook opened this issue Dec 17, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@acook
Copy link

acook commented Dec 17, 2023

Plugin information:

  • OS: Linux, Android
  • Templater version: 1.16.0-2.0.0
  • Obsidian version: 1.4.0-1.5.2
    (settings at end)

Describe the bug

Every so often Templater will completely overwrite the contents of a file. It has been going on since at least September but I only just now was able to prove it.

It just happened to me today and I thought I was losing my mind. Luckily I had Obsidian Git installed and was able to recover the file.

It overwrote the file with my default template. It can happen to old files that had been safe for months or new files that were created that day.

Expected behavior

Files should not be reset/cleared/overwritten/blanked unless explicitly told to. (using synonyms to make finding this issue easier)

Screenshots

This is the one that happened today:

Screenshot from 2023-12-17 04-45-02

This one happened back in September and is a perfect example because I don't ever update UUIDs:

Screenshot from 2023-12-17 04-04-58

I've tracked down around a dozen of notes that this has happened to.

Additional context

The oldest instances I've seen are from around September 2nd, 2023. By looking at the history of .obsidian/plugins/templater-obsidian/manifest.json I can see the Templater version I had at the time was1.16.0. It is still happening with version 2.0.0.

I don't see a way to track the exact version of Obsidian I was using then, but as I stay reasonably up to date and was not using pre-release versions I'm pretty certain it was Obsidian 1.4.0.

What's really odd is that it must be happening in the background. eg not when I'm looking at the file. So perhaps in an inactive tab?

I did not create or open any of those files at the same time on my phone. I can't rule out that it doesn't have something to do with Obsidian Sync since I did open Obsidian on my phone around then to look at a different note. Like maybe Sync recreated it and it got caught in a file creation hook? If so it may be related to #1082?

Templater settings 2023-09-02

{
  "command_timeout": 5,
  "templates_folder": "_attachments/_templates",
  "templates_pairs": [
    [
      "",
      ""
    ]
  ],
  "trigger_on_file_creation": true,
  "auto_jump_to_cursor": true,
  "enable_system_commands": false,
  "shell_path": "",
  "user_scripts_folder": "_attachments/_functions",
  "enable_folder_templates": true,
  "folder_templates": [
    {
      "folder": "/",
      "template": "_attachments/_templates/Generic - Default.md"
    },
    {
      "folder": "1. Dreams",
      "template": "_attachments/_templates/Special - Dream.md"
    },
    {
      "folder": "6. Notes/Daily",
      "template": "_attachments/_templates/Special - Daily Note.md"
    }
  ],
  "syntax_highlighting": true,
  "enabled_templates_hotkeys": [
    ""
  ],
  "startup_templates": [
    ""
  ],
  "enable_ribbon_icon": true
}

Community Plugins Installed

[
  "table-editor-obsidian",
  "auto-card-link",
  "buttons",
  "obsidian-chat-view",
  "obsidian-contextual-typography",
  "dataview",
  "dbfolder",
  "cm-editor-syntax-highlight-obsidian",
  "file-tree-alternative",
  "obsidian-focus-mode",
  "highlightr-plugin",
  "obsidian-kanban",
  "obsidian-list-callouts",
  "obsidian-minimal-settings",
  "numerals",
  "omnisearch",
  "obsidian-outliner",
  "url-into-selection",
  "obsidian-projects",
  "obsidian-read-it-later",
  "simple-embeds",
  "obsidian-style-settings",
  "templater-obsidian",
  "text-extractor",
  "cm-typewriter-scroll-obsidian",
  "obsidian-git",
  "cmdr"
]

Templater settings 2023-12-17

{
  "command_timeout": 5,
  "templates_folder": "_attachments/_templates",
  "templates_pairs": [
    [
      "",
      ""
    ]
  ],
  "trigger_on_file_creation": false,
  "auto_jump_to_cursor": true,
  "enable_system_commands": false,
  "shell_path": "",
  "user_scripts_folder": "_attachments/_functions",
  "enable_folder_templates": true,
  "folder_templates": [
    {
      "folder": "3. Reference/Dictionary",
      "template": "_attachments/_templates/Presets/Z. Dictionary Entry (Template).md"
    },
    {
      "folder": "3. Reference/Software",
      "template": "_attachments/_templates/Presets/Z. Preset - Reference - Software.md"
    },
    {
      "folder": "7. Queries/Experimentasium",
      "template": "none"
    },
    {
      "folder": "1. Dreams",
      "template": "_attachments/_templates/Presets/Z. Preset - Dream.md"
    },
    {
      "folder": "2. Projects",
      "template": "_attachments/_templates/Presets/Z. Preset - Default.md"
    },
    {
      "folder": "3. Reference",
      "template": "_attachments/_templates/Presets/Z. Preset - Default.md"
    },
    {
      "folder": "4. Writing",
      "template": "_attachments/_templates/Presets/Z. Preset - Default.md"
    },
    {
      "folder": "5. Publish",
      "template": "_attachments/_templates/Includes/Y. Default Frontmatter Contents.md"
    },
    {
      "folder": "6. Notes/Daily",
      "template": "_attachments/_templates/Presets/Z. Preset - Daily Note.md"
    },
    {
      "folder": "7. Queries",
      "template": "_attachments/_templates/Presets/Z. Preset - Default.md"
    },
    {
      "folder": "/",
      "template": "_attachments/_templates/Presets/Z. Preset - Default.md"
    }
  ],
  "syntax_highlighting": true,
  "syntax_highlighting_mobile": false,
  "enabled_templates_hotkeys": [
    "_attachments/_templates/Snippets/Daily Note Link (Snippet).md",
    "_attachments/_templates/Presets/Z. Preset - Reference - Software.md"
  ],
  "startup_templates": [
    ""
  ],
  "enable_ribbon_icon": true
}
@acook acook added the bug Something isn't working label Dec 17, 2023
@Zachatoo
Copy link
Collaborator

Zachatoo commented Dec 17, 2023

May be related to #1096, see discussion there for potential workarounds and why this would be hard to fix on the Templater side.

@acook
Copy link
Author

acook commented Dec 18, 2023

Hmm. I've been trying to figure out how Sync might be involved.

The fact that it seems to have started months after I started using Sync seems to make it unlikely that it is just Sync itself, something probably happened in late August that created the issue.

The problem with #1096 is that these aren't new files some of them had been in the vault for months. Looking at my git history there's no correlation between when a file is created, moved, or renamed and when its contents are clobbered.

So unless Sync is just randomly re-creating files during a transfer (maybe because of like an atomic file update??) I'm struggling to figure out how it would create an empty file that is then populated by Templater on a remove machine and subsequently the newer file then transfers back. Particularity for files that aren't actively open on a remote machine. No amount of templates disabling Sync would fix that because a template shouldn't be running at all, right?

Plus that issue popped up 6 months before this one did, so I'm not sure. There could still be related under the hood, but I suspect they're different.

In the meantime I'll disable Templater on my phone and secondary devices and see if it occurs again.

Also, for posterity, even though I'm using Obsidian Git I am only using it locally, not for syncing. So it's not creating any conflicts with Obsidian Sync or anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants