{"record":{"id":"736cef917e3a0899","repo":"siyuan-note/siyuan","slug":"encrypted-attribute-view-snapshot-is-missing-noteb","errorCode":null,"errorMessage":"encrypted attribute view snapshot is missing notebook context","messagePattern":"encrypted attribute view snapshot is missing notebook context","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_render.go","lineNumber":1492,"sourceCode":"\tif err = gulu.JSON.UnmarshalJSON(data, attrView); err != nil {\n\t\tlogging.LogErrorf(\"unmarshal attribute view [%s] failed: %s\", avID, err)\n\t\treturn\n\t}\n\tif err = av.CheckSpec(attrView); nil != err {\n\t\treturn\n\t}\n\tattrView.CustomColorRenderContext = newHistoryAttributeViewCustomColorRenderContext(source.historyDir)\n\tattrView.ResolveDirectColors()\n\n\tviewable, err = renderAttributeView(attrView, \"\", viewID, carrierViewID, query, page, pageSize, groupPaging, false, false, nil, \"\")\n\treturn\n}\n\nfunc decryptHistoricalAttributeView(boxID, avID string, data []byte) ([]byte, error) {\n\tciphertext := util.IsCiphertext(data)\n\tif boxID == \"\" {\n\t\tif ciphertext {\n\t\t\treturn nil, errors.New(\"encrypted attribute view snapshot is missing notebook context\")\n\t\t}\n\t\treturn data, nil\n\t}\n\tif !IsEncryptedBox(boxID) {\n\t\tif ciphertext {\n\t\t\treturn nil, fmt.Errorf(\"encrypted attribute view snapshot has no matching notebook [%s]\", boxID)\n\t\t}\n\t\treturn data, nil\n\t}\n\tif !ciphertext {\n\t\treturn nil, fmt.Errorf(\"encrypted notebook attribute view snapshot is plaintext [%s]\", boxID)\n\t}\n\treturn av.DecryptAVData(boxID, avID, data)\n}\n","sourceCodeStart":1474,"sourceCodeEnd":1507,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_render.go#L1474-L1507","documentation":"decryptHistoricalAttributeView validates snapshot data before decryption. If the snapshot was located without a notebook (boxID is empty — the workspace-global storage/av path matched) but the file content is ciphertext, the kernel has no notebook key context to decrypt it with, so it fails with this error. Plaintext data is returned as-is; encrypted data always requires its owning notebook.","triggerScenarios":"A history snapshot contains an encrypted attribute view file at the global path historyDir/storage/av/<avID>.json (no boxID derivable) while the source notebook had encryption enabled. This happens when a database belonging to an encrypted notebook was indexed/stored globally instead of inside its notebook directory.","commonSituations":"Encrypted-notebook users inspecting history of a database that was moved to the workspace level; snapshots produced by a version that misplaced encrypted AV data in the global storage path; corrupted or re-parented history trees after manual data directory manipulation.","solutions":["Locate the snapshot copy inside its notebook directory (historyDir/<boxID>/storage/av/<avID>.json) so the boxID is available for decryption.","Regenerate a history snapshot from the encrypted notebook so the AV file is stored with notebook context.","If the data is genuinely not sensitive, re-save the attribute view so the snapshot is written unencrypted only if that matches your notebook encryption policy (normally not).","Do not hand-edit or re-encrypt history files; use the documented recovery path in docs/ENCRYPTED-NOTEBOOK.md."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await renderHistoryAttributeView(avID, created);\n} catch (e) {\n  if (String(e.msg).includes(\"missing notebook context\")) {\n    // retry with the snapshot copy stored under its notebook directory (boxID available)\n  }\n}","preventionTips":["Keep encrypted-notebook attribute views stored inside their notebook directory, never at the workspace-global storage/av path","Follow docs/ENCRYPTED-NOTEBOOK.md when moving or restoring encrypted databases"],"tags":["go","encryption","attribute-view","history"],"backgroundTag":"missing-credentials","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"}