{"record":{"id":"ce0a5be5047059c5","repo":"siyuan-note/siyuan","slug":"import-from-local-path-failed-please-check-kernel","errorCode":null,"errorMessage":"import from local path failed, please check kernel log for details","messagePattern":"import from local path failed, please check kernel log for details","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import.go","lineNumber":1208,"sourceCode":"func ImportFromLocalPathSkipRoot(boxID, localPath string, toPath string) (err error) {\n\treturn importFromLocalPath(boxID, localPath, toPath, true)\n}\n\nfunc importFromLocalPath(boxID, localPath string, toPath string, skipRoot bool) (err error) {\n\tbox, err := getOpenedBox(boxID)\n\tif nil != err {\n\t\treturn err\n\t}\n\ttoPath = normalizeBoxDocTarget(boxID, toPath)\n\tutil.PushEndlessProgress(Conf.Language(73))\n\tdefer func() {\n\t\tutil.PushClearProgress()\n\n\t\tif e := recover(); nil != e {\n\t\t\tstack := debug.Stack()\n\t\t\tmsg := fmt.Sprintf(\"PANIC RECOVERED: %v\\n\\t%s\\n\", e, stack)\n\t\t\tlogging.LogErrorf(\"import from local path failed: %s\", msg)\n\t\t\terr = errors.New(\"import from local path failed, please check kernel log for details\")\n\t\t}\n\t}()\n\n\tlockSync()\n\tdefer unlockSync()\n\n\tFlushTxQueue()\n\n\tvar baseHPath, baseTargetPath string\n\tif \"/\" == toPath {\n\t\tbaseHPath = \"/\"\n\t\tbaseTargetPath = \"/\"\n\t} else {\n\t\tblock := treenode.GetBlockTreeRootByPath(boxID, toPath)\n\t\tif nil == block {\n\t\t\tlogging.LogErrorf(\"not found block by path [%s]\", toPath)\n\t\t\treturn nil\n\t\t}","sourceCodeStart":1190,"sourceCodeEnd":1226,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/import.go#L1190-L1226","documentation":"Thrown by importFromLocalPath from a deferred recover() handler. The entire import function body is wrapped in a panic recovery block: if any panic occurs (nil pointer dereference, index out of range, type assertion failure, etc.), the panic value and full stack trace are logged via logging.LogErrorf, and a generic user-facing error is returned. The actual root cause is only visible in the kernel log, not in the returned error.","triggerScenarios":"Calling importFromLocalPath (or ImportFromLocalPath / ImportFromLocalPathSkipRoot) where any code path in the function body panics. The recover at import.go:1204-1209 catches it and converts it to this error. Common panic sources include nil tree from parseStdMd, nil block from GetBlockTreeRootByPath, unexpected node types during AST traversal, or file parsing edge cases.","commonSituations":"Importing a corrupt or malformed Markdown file that triggers an unexpected code path. Importing a file with edge-case content (deeply nested HTML, unusual frontmatter, malformed Markdown syntax). Bug in the import logic that manifests only with specific content patterns. Version incompatibility where the parser expects a different tree structure.","solutions":["Check the kernel log for the PANIC RECOVERED entry — it includes the panic value and full stack trace pinpointing the exact failure.","Try importing the file in smaller pieces to isolate which content triggers the panic.","Test the file in a fresh SiYuan instance to rule out workspace-specific state issues.","Report the panic with the stack trace and the problematic file content to the SiYuan issue tracker.","Update SiYuan to the latest version — the panic may already be fixed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// The function already has internal panic recovery.\n// In the caller, detect the generic error and direct to logs:\nerr := model.ImportFromLocalPath(boxID, localPath, toPath)\nif err != nil && strings.Contains(err.Error(), \"check kernel log for details\") {\n    // A panic occurred — the detailed stack trace is in the kernel log\n    logging.LogErrorf(\"import panicked — check previous log entries for PANIC RECOVERED and stack trace\")\n    // Report to user with guidance\n}","preventionTips":["Always check the kernel log for PANIC RECOVERED entries when this error appears — the stack trace pinpoints the exact cause.","Try importing the file in smaller pieces or a fresh workspace to isolate the trigger.","Update SiYuan to the latest version — known panics may already be fixed.","Report the panic with the stack trace and problematic file to the issue tracker.","Test the file in a standalone SiYuan instance to rule out workspace-specific state."],"tags":["import","panic","markdown","recovery","ast"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}