{"record":{"id":"ef28730805ad8f2a","repo":"siyuan-note/siyuan","slug":"conf-language-79","errorCode":null,"errorMessage":"Conf.Language(79)","messagePattern":"Conf\\.Language\\(79\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import.go","lineNumber":1788,"sourceCode":"\t\t\t\treturn ast.WalkContinue\n\t\t\t})\n\n\t\t\treassignIDUpdated(tree, id, updated)\n\t\t\timportTrees = append(importTrees, tree)\n\n\t\t\thPathsIDs[tree.HPath] = tree.ID\n\t\t\tidPaths[tree.ID] = tree.Path\n\n\t\t\tcount++\n\t\t\tif 0 == count%4 {\n\t\t\t\tutil.PushEndlessProgress(fmt.Sprintf(Conf.language(70), fmt.Sprintf(\"%s\", tree.HPath)))\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t} else { // 导入单个文件\n\t\tfileName := filepath.Base(localPath)\n\t\tif !strings.HasSuffix(fileName, \".md\") && !strings.HasSuffix(fileName, \".markdown\") {\n\t\t\treturn errors.New(Conf.Language(79))\n\t\t}\n\n\t\ttitle := strings.TrimSuffix(fileName, \".markdown\")\n\t\ttitle = strings.TrimSuffix(title, \".md\")\n\t\ttargetPath := strings.TrimSuffix(toPath, \".sy\")\n\t\tid := ast.NewNodeID()\n\t\ttargetPath = path.Join(targetPath, id+\".sy\")\n\t\tvar data []byte\n\t\tdata, err = os.ReadFile(localPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\ttree, yfmRootID, yfmTitle, yfmUpdated := parseStdMd(data)\n\t\tif nil == tree {\n\t\t\tmsg := fmt.Sprintf(\"parse tree [%s] failed\", localPath)\n\t\t\tlogging.LogError(msg)\n\t\t\treturn errors.New(msg)\n\t\t}","sourceCodeStart":1770,"sourceCodeEnd":1806,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import.go#L1770-L1806","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlocalPath = \"/notes/old-export.txt\"\nimportFromLocalPath(localPath, toPath) // -> errors.New(Conf.Language(79))\n// after\nlocalPath = \"/notes/old-export.md\" // converted/renamed to Markdown\nimportFromLocalPath(localPath, toPath)","handlingStrategy":"validation","validationCode":"const base = localPath.split(/[\\\\/]/).pop() ?? \"\";\nif (!/\\.(md|markdown)$/i.test(base)) {\n  throw new Error(`Refusing to import: '${base}' is not a .md/.markdown file`);\n}","typeGuard":"function isMarkdownFile(p: string): boolean {\n  return /\\.(md|markdown)$/i.test(p.split(/[\\\\/]/).pop() ?? \"\");\n}","tryCatchPattern":"try {\n  await api.importFromLocalPath(localPath, toPath);\n} catch (e) {\n  if (String(e.message).includes(\"79\") || isNotMarkdownError(e)) {\n    // prompt user to convert/rename the file to Markdown\n  }\n}","preventionTips":["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"],"tags":["import","file-extension","markdown","validation"],"backgroundTag":"incompatible-source-type","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}