Enveloppe / obsidian-enveloppe

Enveloppe helps you to publish your notes on a GitHub repository from your Obsidian Vault, for free!
https://enveloppe.github.io/
Apache License 2.0
636 stars 39 forks source link

[Bug]: Notes are deleted when trying to upload #355

Closed anareaty closed 3 months ago

anareaty commented 3 months ago

Issue validation

Command used

Upload single current active note

Plugin version

7.2.10

Describe the bug

When I tried to upload a new note, nothing is added, but instead all notes that was already uploaded were deleted from repository. Trying to reupload any file, I get the message that it is added and deleted at the same time. I tried to publish some new notes and noticed that sometimes the new note uploads when you publish in the first time, but gets deleted when you try to reupload it again. Sometimes it doesn't work even the first time.

How to reproduce ?

  1. Create the file in Obsidian named "Test-note".
  2. In plugin settings turn on the option "Auto clean up"
  3. Try to upload the note.
  4. Try to upload the note again.

Minimal Reproducible Example

Test-note.md

---
share: true
---
Text

### Configuration

```JSON
{
  "github": {
    "branch": "main",
    "automaticallyMergePR": true,
    "dryRun": {
      "enable": false,
      "folderName": "github-publisher"
    },
    "tokenPath": "%configDir%/plugins/%pluginID%/env",
    "api": {
      "tiersForApi": "Github Free/Pro/Team (default)",
      "hostname": ""
    },
    "workflow": {
      "commitMessage": "[PUBLISHER] Merge",
      "name": ""
    },
    "verifiedRepo": true
  },
  "upload": {
    "behavior": "yaml",
    "defaultName": "",
    "rootFolder": "",
    "yamlFolderKey": "",
    "frontmatterTitle": {
      "enable": false,
      "key": ""
    },
    "replaceTitle": [],
    "replacePath": [],
    "autoclean": {
      "includeAttachments": false,
      "enable": true,
      "excluded": [
        "images/"
      ]
    },
    "folderNote": {
      "enable": false,
      "rename": "_index.md",
      "addTitle": {
        "enable": false,
        "key": "title"
      }
    },
    "metadataExtractorPath": ""
  },
  "conversion": {
    "hardbreak": false,
    "dataview": true,
    "censorText": [],
    "tags": {
      "inline": false,
      "exclude": [],
      "fields": []
    },
    "links": {
      "internal": true,
      "unshared": true,
      "wiki": false,
      "slugify": true
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [],
    "keySendFile": [],
    "notes": true,
    "folder": "content/images",
    "convertEmbedToLinks": "bake",
    "charConvert": "->",
    "unHandledObsidianExt": [],
    "sendSimpleLinks": false,
    "forcePushAttachments": [],
    "bake": {
      "textBefore": "",
      "textAfter": ""
    }
  },
  "plugin": {
    "shareKey": "share",
    "excludedFolder": [],
    "copyLink": {
      "enable": false,
      "links": "",
      "removePart": [],
      "transform": {
        "toUri": true,
        "slugify": "lower",
        "applyRegex": []
      }
    },
    "setFrontmatterKey": "Set"
  },
  "tabsId": "upload-configuration"
}

Relevant log output

plugin:obsidian-mkdocs-publisher:175 [Enveloppe](GithubBranch.newBranchOnRepo):
 Branch successfully created (status: 201) on anareaty/paperless-forest
plugin:obsidian-mkdocs-publisher:175 [Enveloppe](GithubBranch.uploadOnMultipleRepo):
 Upload Test-note.md:Test-note.md on anareaty/paperless-forest:Obsidian-7-5-2024
plugin:obsidian-mkdocs-publisher:22 

       GET https://api.github.com/repos/anareaty/paperless-forest/contents/Test-note.md?ref=Obsidian-7-5-2024 404 (Not Found)
fetchWrapper @ plugin:obsidian-mkdocs-publisher:22
request2 @ plugin:obsidian-mkdocs-publisher:22
hook @ plugin:obsidian-mkdocs-publisher:24
eval @ plugin:obsidian-mkdocs-publisher:6
Promise.then (async)
register @ plugin:obsidian-mkdocs-publisher:6
Object.assign.endpoint @ plugin:obsidian-mkdocs-publisher:22
upload @ plugin:obsidian-mkdocs-publisher:39
uploadText @ plugin:obsidian-mkdocs-publisher:39
uploadOnMultipleRepo @ plugin:obsidian-mkdocs-publisher:39
await in uploadOnMultipleRepo (async)
publish @ plugin:obsidian-mkdocs-publisher:39
await in publish (async)
shareOneNote @ plugin:obsidian-mkdocs-publisher:27
await in shareOneNote (async)
checkCallback @ plugin:obsidian-mkdocs-publisher:27
RK @ app.js:1
t.onChooseItem @ app.js:1
t.onChooseSuggestion @ app.js:1
t.selectSuggestion @ app.js:1
e.useSelectedItem @ app.js:1
e.onSuggestionClick @ app.js:1
s @ enhance.js:1
plugin:obsidian-mkdocs-publisher:175 [Enveloppe](deleteFromGithubOneRepo):
 trying to delete file : Test-note.md from anareaty/paperless-forest

OS

No response

Anything else?

When trying to upload the note I got this message:

upload-message

Obsidian information

SYSTEM INFO:
    Obsidian version: v1.6.5
    Installer version: v1.6.5
    Operating system: Windows 10 Pro 10.0.19045
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Base theme: light
    Community theme: none
    Snippets enabled: 101
    Restricted mode: off
    Plugins installed: 40
    Plugins enabled: 1
        1: Enveloppe v7.2.10
Mara-Li commented 3 months ago

I already had this bug on my side… I totally forgot what can cause it.

Maybe it's something around the configuration of sharing key and the repository?

Mara-Li commented 3 months ago

Well, your configuration is wrong:

The plugin seems to struggle to found the folder, create a wrong default path, and explode.

anareaty commented 3 months ago

The bug persists if I add the property key:

{ "github": { "branch": "main", "automaticallyMergePR": true, "dryRun": { "enable": false, "folderName": "github-publisher" }, "tokenPath": "%configDir%/plugins/%pluginID%/env", "api": { "tiersForApi": "Github Free/Pro/Team (default)", "hostname": "" }, "workflow": { "commitMessage": "[PUBLISHER] Merge", "name": "" }, "verifiedRepo": true }, "upload": { "behavior": "yaml", "defaultName": "", "rootFolder": "", "yamlFolderKey": "path", "frontmatterTitle": { "enable": false, "key": "" }, "replaceTitle": [], "replacePath": [], "autoclean": { "includeAttachments": false, "enable": true, "excluded": [ "images/" ] }, "folderNote": { "enable": false, "rename": "_index.md", "addTitle": { "enable": false, "key": "title" } }, "metadataExtractorPath": "" }, "conversion": { "hardbreak": false, "dataview": true, "censorText": [], "tags": { "inline": false, "exclude": [], "fields": [] }, "links": { "internal": true, "unshared": true, "wiki": false, "slugify": true } }, "embed": { "attachments": true, "overrideAttachments": [], "keySendFile": [], "notes": true, "folder": "content/images", "convertEmbedToLinks": "bake", "charConvert": "->", "unHandledObsidianExt": [], "sendSimpleLinks": false, "forcePushAttachments": [], "bake": { "textBefore": "", "textAfter": "" } }, "plugin": { "shareKey": "share", "excludedFolder": [], "copyLink": { "enable": false, "links": "", "removePart": [], "transform": { "toUri": true, "slugify": "lower", "applyRegex": [] } }, "setFrontmatterKey": "Set" }, "tabsId": "upload-configuration" }

File:

---
share: true
path: content
---
Text
anareaty commented 3 months ago

upload-message1

Mara-Li commented 3 months ago

Try to provide default folder too

Mara-Li commented 3 months ago

How the file can be published into content if you set no folder?

anareaty commented 3 months ago

This setup does not work too:

{ "github": { "branch": "main", "automaticallyMergePR": true, "dryRun": { "enable": false, "folderName": "github-publisher" }, "tokenPath": "%configDir%/plugins/%pluginID%/env", "api": { "tiersForApi": "Github Free/Pro/Team (default)", "hostname": "" }, "workflow": { "commitMessage": "[PUBLISHER] Merge", "name": "" }, "verifiedRepo": true }, "upload": { "behavior": "yaml", "defaultName": "content", "rootFolder": "content", "yamlFolderKey": "path", "frontmatterTitle": { "enable": false, "key": "" }, "replaceTitle": [], "replacePath": [], "autoclean": { "includeAttachments": false, "enable": true, "excluded": [ "images/" ] }, "folderNote": { "enable": false, "rename": "_index.md", "addTitle": { "enable": false, "key": "title" } }, "metadataExtractorPath": "" }, "conversion": { "hardbreak": false, "dataview": true, "censorText": [], "tags": { "inline": false, "exclude": [], "fields": [] }, "links": { "internal": true, "unshared": true, "wiki": false, "slugify": true } }, "embed": { "attachments": true, "overrideAttachments": [], "keySendFile": [], "notes": true, "folder": "content/images", "convertEmbedToLinks": "bake", "charConvert": "->", "unHandledObsidianExt": [], "sendSimpleLinks": false, "forcePushAttachments": [], "bake": { "textBefore": "", "textAfter": "" } }, "plugin": { "shareKey": "share", "excludedFolder": [], "copyLink": { "enable": false, "links": "", "removePart": [], "transform": { "toUri": true, "slugify": "lower", "applyRegex": [] } }, "setFrontmatterKey": "Set" }, "tabsId": "upload-configuration" }

Mara-Li commented 3 months ago

Please reply to my question…

anareaty commented 3 months ago

What do you mean I set no folder? I set the "content" folder in the "path" variable. Also I should mention that everithing is published just fine if I turn off "Auto clean up" option. And also everything worked in some older realises. But trying to publish the file after the latest uplate wiped all my older published files.

Mara-Li commented 3 months ago

For the second test, did you remove the path from the frontmatter?

Could you please active the developper logs and check what happens ?

The option is in the end of the last tab option

anareaty commented 3 months ago

No, I did not remove the path from the frontmatter. Here are the logs:

[Enveloppe](GithubBranch.newBranchOnRepo):
 Branch successfully created (status: 201) on anareaty/paperless-forest
plugin:obsidian-mkdocs-publisher:175 DEV LOGS [19:16:28.184] GithubBranch.publish:
 Publishing file: Test-note.md
plugin:obsidian-mkdocs-publisher:175 DEV LOGS [19:16:28.191] GithubBranch.publish:
 Publishing Test-note.md to [anareaty/paperless-forest/main] 
plugin:obsidian-mkdocs-publisher:175 [Enveloppe](GithubBranch.uploadOnMultipleRepo):
 Upload Test-note.md:content/Test-note.md on anareaty/paperless-forest:Test-plugins-7-5-2024
plugin:obsidian-mkdocs-publisher:22 

       GET https://api.github.com/repos/anareaty/paperless-forest/contents/content%2FTest-note.md?ref=Test-plugins-7-5-2024 404 (Not Found)
fetchWrapper @ plugin:obsidian-mkdocs-publisher:22
request2 @ plugin:obsidian-mkdocs-publisher:22
hook @ plugin:obsidian-mkdocs-publisher:24
eval @ plugin:obsidian-mkdocs-publisher:6
Promise.then (async)
register @ plugin:obsidian-mkdocs-publisher:6
Object.assign.endpoint @ plugin:obsidian-mkdocs-publisher:22
upload @ plugin:obsidian-mkdocs-publisher:39
uploadText @ plugin:obsidian-mkdocs-publisher:39
uploadOnMultipleRepo @ plugin:obsidian-mkdocs-publisher:39
await in uploadOnMultipleRepo (async)
publish @ plugin:obsidian-mkdocs-publisher:39
await in publish (async)
shareOneNote @ plugin:obsidian-mkdocs-publisher:27
await in shareOneNote (async)
checkCallback @ plugin:obsidian-mkdocs-publisher:27
RK @ app.js:1
t.onChooseItem @ app.js:1
t.onChooseSuggestion @ app.js:1
t.selectSuggestion @ app.js:1
e.useSelectedItem @ app.js:1
e.onSuggestionClick @ app.js:1
s @ enhance.js:1
plugin:obsidian-mkdocs-publisher:175 DEV LOGS [19:16:28.648] GithubBranch.upload:
 The 404 error is normal ! It means that the file does not exist yet. Don't worry ❤️.
plugin:obsidian-mkdocs-publisher:175 [Enveloppe](deleteFromGithubOneRepo):
 trying to delete file : content/Test-note.md from anareaty/paperless-forest
Mara-Li commented 3 months ago

Okay the bug seems to happens in the last version of the plugin

Mara-Li commented 3 months ago

Sorry for the delay, I was pretty tired. The commit dd2aad5 added this bug so reverting should fix it.

Mara-Li commented 3 months ago

Should be fixed in 7.2.11. Sorry again

lovettbarron commented 3 months ago

Sorry to add a comment to the closed. I'm still having this bug pop up with the updated plugin 7.2.11. This is generated when using upload current active note, and none of the "edited" notes are actually edited in this context. Is there a workaround you might suggest, or a "cache clear" option I can try?

Screenshot 2024-07-15 at 13 28 43
Mara-Li commented 3 months ago

Please open a new issue.