siyuan-note/siyuan · error

Conf.Language(79)

Error message

Conf.Language(79)

What it means

SiYuan's local Markdown import (`importFromLocalPath`) only accepts files with a `.md` or `.markdown` extension. When a single file import is requested and the base name fails that suffix check, it aborts with the localized message 'Only Markdown documents are supported for import' (Conf.Language(79)). The file is never read or parsed, so nothing is imported.

Source

Thrown at kernel/model/import.go:1645

				return ast.WalkContinue
			})

			reassignIDUpdated(tree, id, updated)
			importTrees = append(importTrees, tree)

			hPathsIDs[tree.HPath] = tree.ID
			idPaths[tree.ID] = tree.Path

			count++
			if 0 == count%4 {
				util.PushEndlessProgress(fmt.Sprintf(Conf.language(70), fmt.Sprintf("%s", tree.HPath)))
			}
			return nil
		})
	} else { // 导入单个文件
		fileName := filepath.Base(localPath)
		if !strings.HasSuffix(fileName, ".md") && !strings.HasSuffix(fileName, ".markdown") {
			return errors.New(Conf.Language(79))
		}

		title := strings.TrimSuffix(fileName, ".markdown")
		title = strings.TrimSuffix(title, ".md")
		targetPath := strings.TrimSuffix(toPath, ".sy")
		id := ast.NewNodeID()
		targetPath = path.Join(targetPath, id+".sy")
		var data []byte
		data, err = os.ReadFile(localPath)
		if err != nil {
			return err
		}
		tree, yfmRootID, yfmTitle, yfmUpdated := parseStdMd(data)
		if nil == tree {
			msg := fmt.Sprintf("parse tree [%s] failed", localPath)
			logging.LogError(msg)
			return errors.New(msg)
		}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Convert the file to Markdown (`.md` or `.markdown`) and retry the import
  2. Rename the file extension to `.md` if the content is already Markdown (fix casing, e.g. `.MD` -> `.md`)
  3. For non-Markdown formats, use a dedicated converter (e.g. pandoc) to Markdown first
  4. If importing a folder, ensure the path is a directory so the `else` single-file branch is not taken

Example fix

// before
localPath = "/notes/meeting.txt" // rejected: Conf.Language(79)
// after
localPath = "/notes/meeting.md" // converted to Markdown first
Defensive patterns

Strategy: validation

Validate before calling

const localPath = "/notes/meeting.md"
const base = localPath.split(/[\\/]/).pop()!.toLowerCase()
if (!base.endsWith(".md") && !base.endsWith(".markdown")) {
  throw new Error("convert to Markdown before importing")
}

Try / catch

try { await importFromLocalPath(path) } catch (e) { if (e.msg === conf.Language(79)) showToast("Only .md/.markdown files are supported") }

Prevention

When it happens

Trigger: Calling `ImportFromLocalPath` / `ImportFromLocalPathSkipRoot` with `localPath` pointing to a single non-Markdown file (e.g. `.txt`, `.html`, `.docx`, or even `.MD` uppercase, since the suffix check is case-sensitive via `strings.HasSuffix`).

Common situations: Users drag-and-drop a text/HTML/Word file onto the editor expecting conversion; scripts or plugins pass a notebook export path of the wrong type; case-sensitive extension like `.MD` on Linux where the check rejects it.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/ef28730805ad8f2a. Report an issue: GitHub.