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
613 stars 38 forks source link

[Bug]: Couldn't upload Attachments with Obsidian folder structure while using the Folder Path replacer #314

Closed vu-truong closed 6 months ago

vu-truong commented 6 months ago

Issue validation

Command used

Upload single current active note

Plugin version

6.15.5

Describe the bug

Hi, Lisandra I've found that I couldn't upload Attachments with Obsidian folder structure while using the Folder Path replacer:

image

If I remove the Folder Path replacer, everything is okay. So I think there is a bug about replacing the Folder Path when uploading Attachments with Obsidian folder structure.

Here is my vault:

image

Here is my attachment config:

image

And here is the error:

image

How to reproduce ?

No response

Minimal Reproducible Example

---
share: true
comments: false
hidden: true
title: Home
---

![[Attachments/discord.png]]

Configuration

{
  "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": "obsidian",
    "defaultName": "docs",
    "rootFolder": "",
    "yamlFolderKey": "",
    "frontmatterTitle": {
      "enable": false,
      "key": "title"
    },
    "replaceTitle": [],
    "replacePath": [
      {
        "regex": "MyBlog",
        "replacement": "",
        "type": "path"
      }
    ],
    "autoclean": {
      "enable": false,
      "excluded": []
    },
    "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": false,
      "unshared": false,
      "wiki": false,
      "slugify": "disable"
    }
  },
  "embed": {
    "attachments": true,
    "overrideAttachments": [],
    "keySendFile": [],
    "notes": false,
    "folder": "docs/Attachments",
    "convertEmbedToLinks": "keep",
    "charConvert": "->",
    "useObsidianFolder": true
  },
  "plugin": {
    "shareKey": "share",
    "excludedFolder": [],
    "copyLink": {
      "enable": false,
      "links": "",
      "removePart": [],
      "transform": {
        "toUri": true,
        "slugify": "lower",
        "applyRegex": []
      }
    },
    "setFrontmatterKey": "Set"
  }
}

Relevant log output

No response

OS

Windows

Anything else?

No response

Obsidian information

SYSTEM INFO:
    Obsidian version: v1.5.3
    Installer version: v1.4.16
    Operating system: Windows 10 Home Single Language 10.0.22621
    Login status: not logged in
    Insider build toggle: off
    Live preview: off
    Base theme: adapt to system
    Community theme: none
    Snippets enabled: 0
    Restricted mode: off
    Plugins installed: 1
    Plugins enabled: 1
        1: Github Publisher v6.15.5

RECOMMENDATIONS:
    Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.
Mara-Li commented 6 months ago

Found what cause the 422 error : HttpError: path contains a malformed path component: {"resource":"Commit","field":"path","code":"invalid"}

I forgot to normalizePath after the regex