{"record":{"id":"d224d66be1adf20a","repo":"siyuan-note/siyuan","slug":"new-attribute-view-item-document-in-an-encrypted-n","errorCode":null,"errorMessage":"new attribute view item document in an encrypted notebook must be saved in the current notebook","messagePattern":"new attribute view item document in an encrypted notebook must be saved in the current notebook","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_new_item.go","lineNumber":549,"sourceCode":"\t\t}\n\t\tif nil == Conf.Box(boxID) {\n\t\t\treturn \"\", \"\", false, ErrBoxNotFound\n\t\t}\n\t\tif err = validateNewItemSaveBox(currentBoxID, boxID); nil != err {\n\t\t\treturn \"\", \"\", false, err\n\t\t}\n\t\treturn boxID, location.PathTemplate, false, nil\n\t}\n\n\tinherited = true\n\tboxID, pathTemplate = ResolveDocCreateSaveLocation(currentBoxID)\n\terr = validateNewItemSaveBox(currentBoxID, boxID)\n\treturn\n}\n\nfunc validateNewItemSaveBox(currentBoxID, targetBoxID string) error {\n\tif IsEncryptedBox(currentBoxID) && currentBoxID != targetBoxID {\n\t\treturn errors.New(\"new attribute view item document in an encrypted notebook must be saved in the current notebook\")\n\t}\n\treturn nil\n}\n\nfunc newItemParentPathTemplate(renderedPath string) string {\n\tif \"\" == renderedPath || strings.HasSuffix(renderedPath, \"/\") {\n\t\treturn renderedPath\n\t}\n\tisAbsolute := strings.HasPrefix(renderedPath, \"/\")\n\tsegments := strings.FieldsFunc(renderedPath, func(r rune) bool { return '/' == r })\n\tif 1 >= len(segments) {\n\t\tif isAbsolute {\n\t\t\treturn \"/\"\n\t\t}\n\t\treturn \"\"\n\t}\n\tparent := strings.Join(segments[:len(segments)-1], \"/\")\n\tif isAbsolute {","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_new_item.go#L531-L567","documentation":"validateNewItemSaveBox enforces that when the database block lives in an encrypted notebook, any document created from a new-item template must be saved in that same notebook. If the template's save-location configuration resolves to a different notebook (targetBoxID), creation is refused. This protects encrypted-notebook invariants: content must never be written outside the encrypted box.","triggerScenarios":"Creating an attribute-view item document in an encrypted notebook whose template SaveLocation (custom notebook/path) points to a different notebook, via CreateAttributeViewItemDocs or createAttributeViewItem's document path.","commonSituations":"A shared template configured with SaveLocation targeting a specific normal notebook, then reused in an encrypted notebook; user later converts a notebook to encrypted while templates still point elsewhere.","solutions":["Edit the template's save location so the target notebook equals the notebook containing the database (the current box)","Clear the template's custom save-location override so documents inherit the current notebook","If cross-notebook saving is required, move the database (and its block) out of the encrypted notebook first"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if model.IsEncryptedBox(currentBoxID) && tpl.SaveLocation != nil && tpl.SaveLocation.BoxID != \"\" && tpl.SaveLocation.BoxID != currentBoxID {\n    return errors.New(\"template save location targets another notebook\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep document-template save locations pointing at the database's own notebook when the notebook is encrypted","Re-check templates after converting a notebook to encrypted","Avoid sharing templates with hard-coded target notebooks into encrypted notebooks"],"tags":["attribute-view","encrypted-notebook","go-kernel"],"backgroundTag":"conflicting-config-options","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"}