{"record":{"id":"a86c37051d7abf19","repo":"siyuan-note/siyuan","slug":"exporting-encrypted-and-normal-notebook-resources","errorCode":null,"errorMessage":"exporting encrypted and normal notebook resources together is not supported","messagePattern":"exporting encrypted and normal notebook resources together is not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/export.go","lineNumber":1022,"sourceCode":"\t\t}\n\t\tboxID := ExtractBoxIDFromAssetsPath(resourceFullPath)\n\t\tif boxID == \"\" || !IsEncryptedBox(boxID) {\n\t\t\thasNormalResource = true\n\t\t\tcontinue\n\t\t}\n\n\t\tassetsPath := filepath.Join(util.DataDir, boxID, \"assets\")\n\t\tif !gulu.File.IsSubPath(assetsPath, resourceFullPath) {\n\t\t\treturn \"\", errors.New(\"exporting non-asset files from encrypted notebooks is not supported\")\n\t\t}\n\t\tif encryptedBoxID == \"\" {\n\t\t\tencryptedBoxID = boxID\n\t\t} else if encryptedBoxID != boxID {\n\t\t\treturn \"\", errors.New(\"exporting resources across encrypted notebook boundaries is not supported\")\n\t\t}\n\t}\n\tif encryptedBoxID != \"\" && hasNormalResource {\n\t\treturn \"\", errors.New(\"exporting encrypted and normal notebook resources together is not supported\")\n\t}\n\treturn\n}\n\nfunc ExportPreview(id string, fillCSSVar bool, accessChecker ...EmbedBlockAccessChecker) (retStdHTML string) {\n\tif exportErr := withExportReadLockByBlockID(id, func() error {\n\t\tblockRefMode := Conf.Export.BlockRefMode\n\t\tbt := getExportBlockTree(id)\n\t\tif nil == bt {\n\t\t\treturn nil\n\t\t}\n\n\t\ttree := prepareExportTree(bt)\n\t\tif numberErr := applyHeadingNumbersForExport(tree, bt, false); nil != numberErr {\n\t\t\treturn numberErr\n\t\t}\n\t\ttree, exportTreeErr := exportTree(tree, false, true, false, true,\n\t\t\tblockRefMode, Conf.Export.BlockEmbedMode, Conf.Export.FileAnnotationRefMode,","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/export.go#L1004-L1040","documentation":"A single export batch may contain resources from encrypted notebooks OR from normal notebooks, but not both. The mixed set has no consistent decrypt/copy strategy, so exportResourcesEncryptedBox rejects it when at least one encrypted-box resource and at least one normal resource are present.","triggerScenarios":"ExportResources called with asset paths where some belong to encrypted boxes (IsEncryptedBox true) and others to regular notebooks.","commonSituations":"Multi-select export of images across notebooks after enabling encryption on some notebooks; plugin collecting all assets referenced by a document that embeds cross-notebook assets.","solutions":["Partition the resource list into encrypted and normal sets and issue separate ExportResources calls per set","Handle the error in the UI by informing the user to export encrypted and normal notebook resources separately"],"exampleFix":"// before\nExportResources([]string{\"encBox/assets/a.png\", \"normalBox/assets/b.png\"})\n// after\nExportResources([]string{\"encBox/assets/a.png\"})\nExportResources([]string{\"normalBox/assets/b.png\"})","handlingStrategy":"validation","validationCode":"function partitionByEncryption(paths, isEncryptedBox) {\n  const encrypted = paths.filter(p => isEncryptedBox(p.split('/')[0]));\n  const normal = paths.filter(p => !isEncryptedBox(p.split('/')[0]));\n  return { encrypted, normal };\n}","typeGuard":null,"tryCatchPattern":"try { await exportResources(mixedPaths); }\ncatch (e) {\n  if (String(e).includes('encrypted and normal notebook resources together')) {\n    const { encrypted, normal } = partitionByEncryption(mixedPaths, isEncrypted);\n    await exportResources(encrypted);\n    await exportResources(normal);\n  }\n}","preventionTips":["Partition mixed selection exports into encrypted-only and normal-only batches","Inform users that encrypted and normal notebook resources must be exported separately","Track notebook encryption state in the UI before assembling export lists"],"tags":["export","encrypted-notebook","mixed-resources"],"backgroundTag":"unsupported-operation","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"}