siyuan-note/siyuan · error
Conf.Language(79)
Error message
Conf.Language(79)
What it means
SiYuan's local Markdown import (`importFromLocalPath`, exposed via `ImportFromLocalPath`/`ImportFromLocalPathSkipRoot`) only accepts `.md`/`.markdown` files when importing a single file. If `filepath.Base(localPath)` has neither suffix, the kernel aborts and returns the localized user message at i18n key 79 ("only Markdown files are supported"). It is a pre-parse extension check, not a file-read failure.
Solutions
- Rename or convert the file so its extension is `.md` or `.markdown` before importing
- If importing many files, put them in a folder and import the folder (the directory branch does not require the single-file extension check for the root path)
- Convert other formats (HTML, DOCX, txt) to Markdown with an external tool first
Example fix
// before localPath = "/notes/old-export.txt" importFromLocalPath(localPath, toPath) // -> errors.New(Conf.Language(79)) // after localPath = "/notes/old-export.md" // converted/renamed to Markdown importFromLocalPath(localPath, toPath)
Defensive patterns
Strategy: validation
Validate before calling
const base = localPath.split(/[\\/]/).pop() ?? "";
if (!/\.(md|markdown)$/i.test(base)) {
throw new Error(`Refusing to import: '${base}' is not a .md/.markdown file`);
} Type guard
function isMarkdownFile(p: string): boolean {
return /\.(md|markdown)$/i.test(p.split(/[\\/]/).pop() ?? "");
} Try / catch
try {
await api.importFromLocalPath(localPath, toPath);
} catch (e) {
if (String(e.message).includes("79") || isNotMarkdownError(e)) {
// prompt user to convert/rename the file to Markdown
}
} Prevention
- Always check the file extension before invoking single-file import
- Convert external formats (txt/html/docx) to Markdown upstream
- Prefer folder import when batch-importing mixed content
When it happens
Trigger: Calling the import API (`/api/import/importFromLocalPath`) with a single-file `localPath` whose base name lacks a `.md` or `.markdown` extension — e.g. a `.txt`, `.html`, `.mdown`, or extensionless file; or a path with mixed case/odd extension the check does not match.
Common situations: Users drag a Notion/Txt/Word export that is not Markdown; scripts pass an `.mdown` or uppercase `.MD` variant; a directory was expected to be a folder but is actually a single non-Markdown file path.
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
- 199
- CardDAV: address file extension name is invalid
- Conf.Language(0)
- Conf.Language(199)
- Conf.Language(199)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/ef28730805ad8f2a.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/import.go:1788
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 9f775e8a12)