{"record":{"id":"6b33c253b6d98879","repo":"siyuan-note/siyuan","slug":"199","errorCode":"199","errorMessage":"This is not a valid .sy.zip archive. If the archive was exported from [Settings], please import it from [Settings]","messagePattern":"This is not a valid \\.sy\\.zip archive\\. If the archive was exported from \\[Settings\\], please import it from \\[Settings\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import.go","lineNumber":198,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\tif d == nil {\n\t\t\treturn nil\n\t\t}\n\t\tif !d.IsDir() && strings.HasSuffix(d.Name(), \".sy\") {\n\t\t\tsyPaths = append(syPaths, path)\n\t\t}\n\t\treturn nil\n\t})\n\n\tentries, err := os.ReadDir(unzipPath)\n\tif err != nil {\n\t\tlogging.LogErrorf(\"read unzip dir [%s] failed: %s\", unzipPath, err)\n\t\treturn\n\t}\n\tif 1 != len(entries) || !entries[0].IsDir() || len(syPaths) < 1 {\n\t\tlogging.LogErrorf(\"invalid .sy.zip [%v]\", entries)\n\t\terr = errors.New(Conf.Language(199))\n\t\treturn\n\t}\n\tunzipRootPath := filepath.Join(unzipPath, entries[0].Name())\n\tname := filepath.Base(unzipRootPath)\n\tif strings.HasPrefix(name, \"data-20\") && len(\"data-20230321175442\") == len(name) {\n\t\tlogging.LogErrorf(\"invalid .sy.zip [unzipRootPath=%s, baseName=%s]\", unzipRootPath, name)\n\t\terr = errors.New(Conf.Language(199))\n\t\treturn\n\t}\n\tvar importedBoxConf *conf.BoxConf\n\timportedConfPath := filepath.Join(unzipRootPath, \".siyuan\", \"conf.json\")\n\thasImportedBoxConf := filelock.IsExist(importedConfPath)\n\tvar importedMetadataErr error\n\tif hasImportedBoxConf {\n\t\tconfData, readErr := filelock.ReadFile(importedConfPath)\n\t\tif readErr == nil {\n\t\t\timportedBoxConf = conf.NewBoxConf()\n\t\t\tif unmarshalErr := gulu.JSON.UnmarshalJSON(confData, importedBoxConf); unmarshalErr != nil {","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/import.go#L180-L216","documentation":"Returned by importSY (import.go:198) as Conf.Language(199) = \"This is not a valid .sy.zip archive. If the archive was exported from [Settings], please import it from [Settings]\". Fires when the unzipped directory does not contain exactly one top-level directory entry or contains zero .sy files. The kernel expects a single root folder holding the .sy tree; anything else (flat zip, multi-root, empty zip) is rejected as malformed.","triggerScenarios":"POST /api/import/importSY, importSYNotebook, or importSYAuto with a zip that is not a SiYuan .sy.zip export: a generic zip, a re-zipped folder whose structure was flattened, an empty archive, or a Data export mistaken for a notebook/doc export.","commonSituations":"User re-compressed the export with a different tool that changed the layout; user exported from Settings - Export - Data and tries to import via the notebook import dialog (wrong direction); corrupted download.","solutions":["Re-export the notebook/document from SiYuan and import the untouched .sy.zip.","If the user exported full data from Settings, import it from Settings - Export - Import Data, not the notebook import dialog.","Inspect the zip's top-level layout: it must be exactly one directory containing .sy files."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Inspect the zip before importing: it must contain exactly one top-level dir holding .sy files.\nentries, _ := zip.OpenReader(zipPath)\ndefer entries.Close()\ntopDirs := 0; hasSy := false\nfor _, f := range entries.File {\n    seg := strings.Split(strings.TrimPrefix(f.Name, \"/\"), \"/\")[0]\n    if seg != \"\" { topDirs = 1 }\n    if strings.HasSuffix(f.Name, \".sy\") { hasSy = true }\n}\nif topDirs != 1 || !hasSy { return errors.New(Conf.Language(199)) }","typeGuard":null,"tryCatchPattern":"err := model.ImportSY(zipPath, boxID, toPath)\nif err != nil && err.Error() == Conf.Language(199) {\n    // tell user the archive is not a valid .sy.zip; re-export or use Settings import\n}","preventionTips":["Do not re-compress .sy.zip exports with third-party tools that change layout.","Use the matching import entry point: notebook/doc import vs Settings - Data import.","Verify the zip has one top-level directory containing .sy files before upload."],"tags":["import","sy-zip","validation","file-format"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}