{"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":1518,"sourceCode":"\t\treturn \"\", \"\", fmt.Errorf(\"target document not found in notebook %s: %s\", boxID, toPath)\n\t}\n\treturn block.HPath, strings.TrimSuffix(block.Path, \".sy\"), nil\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\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\tbaseHPath, baseTargetPath, err := resolveMarkdownImportTarget(boxID, toPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\ttargetDocDirLocalPath := filepath.Join(util.DataDir, boxID,\n\t\tfilepath.FromSlash(strings.TrimPrefix(baseTargetPath, \"/\")))\n\tassetDirPath := GetImportAssetsDir(boxID, targetDocDirLocalPath)\n\tif err = os.MkdirAll(assetDirPath, 0755); err != nil {\n\t\treturn\n\t}","sourceCodeStart":1500,"sourceCodeEnd":1536,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import.go#L1500-L1536","documentation":"importFromLocalPath recovers from any panic occurring during the Markdown import (recursive parsing, tree building, asset copying) in its deferred handler. Instead of propagating the panic, it logs the full stack trace to the kernel log and converts it into this generic user-facing error, because the original panic message is too internal to show in the UI.","triggerScenarios":"Any panic inside the local-path import flow — malformed Markdown edge cases in the parser, nil pointer in tree construction, or a bug triggered by specific file contents — during ImportFromLocalPath or ImportFromLocalPathSkipRoot.","commonSituations":"Importing a large or pathological Markdown tree that hits a Lute parser edge case; concurrent modification of source files during import; kernel bugs on specific content patterns.","solutions":["Open the kernel log and search for 'PANIC RECOVERED' to find the exact panic and stack trace","Identify which local file/content triggered it and try importing in smaller batches to isolate it","Check for an existing GitHub issue with the stack trace; report it with the log excerpt and the offending Markdown file if new","Retry after upgrading to the latest SiYuan version, as parser panics are often fixed upstream"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Caller-side: pre-scan the local Markdown tree for pathological content (huge files, broken links)\nfilepath.Walk(localPath, func(p string, info os.FileInfo, err error) error {\n    if err != nil { return err }\n    if info.Mode().IsRegular() && info.Size() > 100<<20 {\n        return fmt.Errorf(\"file %s is unusually large for Markdown import\", p)\n    }\n    return nil\n})","typeGuard":null,"tryCatchPattern":"err := model.ImportFromLocalPath(boxID, localPath, toPath)\nif err != nil && strings.Contains(err.Error(), \"please check kernel log\") {\n    // a panic was recovered; grep the kernel log for 'PANIC RECOVERED'\n    // to find the stack trace and offending content, then retry in smaller batches\n    log.Printf(\"import panicked; inspect kernel log\")\n}","preventionTips":["Import large Markdown trees in smaller batches to isolate problematic content","Keep the kernel up to date — parser panics are often fixed upstream","Avoid mutating source files while an import is running","When a panic occurs, attach the kernel log 'PANIC RECOVERED' excerpt to a bug report"],"tags":["panic","import","markdown","internal-error"],"backgroundTag":"internal-invariant-violation","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"}