siyuan-note/siyuan · error

Conf.Language(198)

Error message

Conf.Language(198)

What it means

The unzipped data.zip contains .sy document files at '*/*.sy' depth, meaning the archive holds raw notebook directories directly instead of the expected single top-level 'data' directory wrapping them. ImportData rejects this with the localized message i18n key 198 (Conf.Language(198)).

Solutions

  1. Rebuild the zip so all content sits under exactly one top-level directory (the 'data' folder), then re-import
  2. Use SiYuan's built-in 'Export data.zip' (Settings - Export) instead of manually zipping the workspace
  3. Unzip locally, restructure into <top-dir>/<notebook>/*.sy, re-zip, and retry

Example fix

// before (rejected): notebooks at zip root level
// data.zip -> notebook-xxx/*.sy
// after (accepted): single top-level data directory
// data.zip -> data/notebook-xxx/*.sy
Defensive patterns

Strategy: validation

Validate before calling

// Caller-side: verify the zip layout matches data/<notebook>/*.sy before import
entries, _ := zip.OpenReader(zipPath)
hasSyAtRoot := false
for _, f := range entries.File {
    parts := strings.SplitN(f.Name, "/", 3)
    if len(parts) == 3 && strings.HasSuffix(parts[2], ".sy") {
        // .sy two levels deep: notebook directly under archive root — will be rejected
        hasSyAtRoot = true
    }
}
if hasSyAtRoot { return errors.New("zip must contain a single top-level data directory") }

Prevention

When it happens

Trigger: ImportData where filepath.Glob(unzipPath/*/*.sy) matches at least one file — e.g. the zip was built from the workspace root so notebooks sit one level down instead of under a single 'data/' folder.

Common situations: Users zipping the workspace directory themselves instead of using SiYuan's 'Export data.zip'; zips that mix notebook folders and other files at the top level.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/import.go:1414

	logging.LogInfof("import data from [%s]", zipPath)
	baseName := filepath.Base(zipPath)
	ext := filepath.Ext(baseName)
	baseName = strings.TrimSuffix(baseName, ext)
	unzipPath := filepath.Join(filepath.Dir(zipPath), baseName)
	err = gulu.Zip.Unzip(zipPath, unzipPath)
	if err != nil {
		return
	}
	defer os.RemoveAll(unzipPath)

	files, err := filepath.Glob(filepath.Join(unzipPath, "*/*.sy"))
	if err != nil {
		logging.LogErrorf("check data.zip failed: %s", err)
		return errors.New("check data.zip failed")
	}
	if 0 < len(files) {
		return errors.New(Conf.Language(198))
	}
	dirs, err := os.ReadDir(unzipPath)
	if err != nil {
		logging.LogErrorf("check data.zip failed: %s", err)
		return errors.New("check data.zip failed")
	}
	if 1 != len(dirs) {
		return errors.New(Conf.Language(198))
	}

	tmpDataPath := filepath.Join(unzipPath, dirs[0].Name())
	tmpDataEmojisPath := filepath.Join(tmpDataPath, "emojis")
	filelock.Walk(tmpDataEmojisPath, func(path string, d fs.DirEntry, err error) error {
		if err != nil {
			return err
		}
		if d == nil {
			return nil

View on GitHub (pinned to 9f775e8a12)