siyuan-note/siyuan · error

import from local path failed, please check kernel log for…

Error message

import from local path failed, please check kernel log for details

What it means

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.

Solutions

  1. Open the kernel log and search for 'PANIC RECOVERED' to find the exact panic and stack trace
  2. Identify which local file/content triggered it and try importing in smaller batches to isolate it
  3. Check for an existing GitHub issue with the stack trace; report it with the log excerpt and the offending Markdown file if new
  4. Retry after upgrading to the latest SiYuan version, as parser panics are often fixed upstream
Defensive patterns

Strategy: try-catch

Validate before calling

// Caller-side: pre-scan the local Markdown tree for pathological content (huge files, broken links)
filepath.Walk(localPath, func(p string, info os.FileInfo, err error) error {
    if err != nil { return err }
    if info.Mode().IsRegular() && info.Size() > 100<<20 {
        return fmt.Errorf("file %s is unusually large for Markdown import", p)
    }
    return nil
})

Try / catch

err := model.ImportFromLocalPath(boxID, localPath, toPath)
if err != nil && strings.Contains(err.Error(), "please check kernel log") {
    // a panic was recovered; grep the kernel log for 'PANIC RECOVERED'
    // to find the stack trace and offending content, then retry in smaller batches
    log.Printf("import panicked; inspect kernel log")
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/ce0a5be5047059c5. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/import.go:1518

		return "", "", fmt.Errorf("target document not found in notebook %s: %s", boxID, toPath)
	}
	return block.HPath, strings.TrimSuffix(block.Path, ".sy"), nil
}

func importFromLocalPath(boxID, localPath string, toPath string, skipRoot bool) (err error) {
	box, err := getOpenedBox(boxID)
	if nil != err {
		return err
	}
	util.PushEndlessProgress(Conf.Language(73))
	defer func() {
		util.PushClearProgress()

		if e := recover(); nil != e {
			stack := debug.Stack()
			msg := fmt.Sprintf("PANIC RECOVERED: %v\n\t%s\n", e, stack)
			logging.LogErrorf("import from local path failed: %s", msg)
			err = errors.New("import from local path failed, please check kernel log for details")
		}
	}()

	lockSync()
	defer unlockSync()

	FlushTxQueue()

	baseHPath, baseTargetPath, err := resolveMarkdownImportTarget(boxID, toPath)
	if err != nil {
		return err
	}
	targetDocDirLocalPath := filepath.Join(util.DataDir, boxID,
		filepath.FromSlash(strings.TrimPrefix(baseTargetPath, "/")))
	assetDirPath := GetImportAssetsDir(boxID, targetDocDirLocalPath)
	if err = os.MkdirAll(assetDirPath, 0755); err != nil {
		return
	}

View on GitHub (pinned to 9f775e8a12)