{"record":{"id":"702b2a49881ef42f","repo":"siyuan-note/siyuan","slug":"parse-imported-notebook-conf-s-failed-w","errorCode":null,"errorMessage":"parse imported notebook conf [%s] failed: %w","messagePattern":"parse imported notebook conf \\[(.+?)\\] failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import.go","lineNumber":1340,"sourceCode":"\tfor _, entry := range dirs {\n\t\tif !entry.IsDir() || !ast.IsNodeIDPattern(entry.Name()) {\n\t\t\tcontinue\n\t\t}\n\n\t\tboxID := entry.Name()\n\t\tboxDir := filepath.Join(tmpDataPath, boxID)\n\t\tconfPath := filepath.Join(boxDir, \".siyuan\", \"conf.json\")\n\t\tbackupPath := filepath.Join(boxDir, \".siyuan\", notebookCryptoBackupFilename)\n\n\t\tvar boxConf *conf.BoxConf\n\t\tif filelock.IsExist(confPath) {\n\t\t\tdata, readErr := filelock.ReadFile(confPath)\n\t\t\tif readErr != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"read imported notebook conf [%s] failed: %w\", boxID, readErr)\n\t\t\t}\n\t\t\tboxConf = conf.NewBoxConf()\n\t\t\tif unmarshalErr := gulu.JSON.UnmarshalJSON(data, boxConf); unmarshalErr != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parse imported notebook conf [%s] failed: %w\", boxID, unmarshalErr)\n\t\t\t}\n\t\t}\n\n\t\tvar backup *conf.BoxEncryption\n\t\tif filelock.IsExist(backupPath) {\n\t\t\tbackup, err = readBoxEncryptionFile(backupPath)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid imported notebook identity [%s]: %w\", boxID, err)\n\t\t\t}\n\t\t}\n\n\t\tvar boxCrypt *conf.BoxEncryption\n\t\tif boxConf != nil && boxConf.Encrypted {\n\t\t\tif boxConf.BoxCrypt != nil && validateBoxEncryption(boxConf.BoxCrypt) == nil {\n\t\t\t\tboxCrypt = boxConf.BoxCrypt\n\t\t\t} else {\n\t\t\t\tboxCrypt = backup\n\t\t\t}","sourceCodeStart":1322,"sourceCodeEnd":1358,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import.go#L1322-L1358","documentation":"In validateImportedNotebookIdentities, after successfully reading an imported notebook's .siyuan/conf.json, the JSON must unmarshal into a conf.BoxConf. If the content is not valid JSON or has an incompatible shape, the function returns 'parse imported notebook conf [%s] failed' wrapping the unmarshal error, because boxConf fields (including Encrypted/BoxCrypt identity) cannot be trusted.","triggerScenarios":"ImportData importing a notebook whose .siyuan/conf.json is corrupt, truncated, hand-edited to invalid JSON, or produced by an incompatible tool/older format that gulu.JSON.UnmarshalJSON cannot decode into conf.BoxConf.","commonSituations":"1) Archive extraction truncated by low disk space. 2) conf.json edited manually and saved with a syntax error. 3) Third-party tool writing a differently shaped conf.json. 4) Binary corruption from a failed sync/transfer.","solutions":["Open the imported notebook's .siyuan/conf.json and validate it as JSON (e.g. jq .); fix syntax errors if hand-edited.","Re-export or re-download the notebook archive from the source workspace to get an intact conf.json.","If only that notebook is corrupt, remove it from the import set, import the rest, then restore the notebook from a SiYuan snapshot/history backup.","Compare with a valid conf.json from a working notebook to restore required fields (name, encrypted, etc.)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const raw = await fs.promises.readFile(path.join(boxDir, '.siyuan', 'conf.json'), 'utf8');\nJSON.parse(raw); // throws SyntaxError before the API call if the conf is malformed","typeGuard":"function isValidBoxConf(v) {\n  return v !== null && typeof v === 'object' && !Array.isArray(v) && typeof v.name === 'string';\n}","tryCatchPattern":"try {\n  await importData(src);\n} catch (e) {\n  if (/parse imported notebook conf/.test(e.msg)) {\n    console.error('Validate/repair .siyuan/conf.json JSON, or re-export the notebook');\n  }\n  throw e;\n}","preventionTips":["Never hand-edit conf.json without re-validating as JSON","Validate every notebook's conf.json in an archive before importing","Re-export from a healthy source workspace instead of repairing corrupt archives"],"tags":["json","config","parse","import","siyuan"],"backgroundTag":"json-unmarshal-failed","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"}