{"record":{"id":"ba25f11a06d70b6f","repo":"siyuan-note/siyuan","slug":"renaming-assets-in-encrypted-notebooks-is-not-supp","errorCode":null,"errorMessage":"renaming assets in encrypted notebooks is not supported","messagePattern":"renaming assets in encrypted notebooks is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/assets.go","lineNumber":1496,"sourceCode":"\tutil.RemoveAssetText(relativePath)\n\n\tIncSync()\n\n\tindexHistoryDir(filepath.Base(historyDir), util.NewLute())\n\tcache.RemoveAsset(relativePath)\n\treturn\n}\n\nfunc RenameAsset(oldPath, newName string) (newPath string, err error) {\n\tutil.PushEndlessProgress(Conf.Language(110))\n\tdefer util.PushClearProgress()\n\n\toldCleanPath := AssetPathWithoutQuery(oldPath)\n\n\t// 加密笔记本的资源磁盘文件名参与 AAD，重命名需要重新封装密文，当前不支持。\n\tif absPath, absErr := GetAssetAbsPathInBox(oldPath, \"\"); absErr == nil {\n\t\tif IsEncryptedAssetPath(absPath) {\n\t\t\terr = errors.New(\"renaming assets in encrypted notebooks is not supported\")\n\t\t\treturn\n\t\t}\n\t}\n\n\tnewName = strings.TrimSpace(newName)\n\tnewName = util.FilterUploadFileName(newName)\n\tif path.Base(oldCleanPath) == newName {\n\t\treturn\n\t}\n\tif \"\" == newName {\n\t\treturn\n\t}\n\n\tif !gulu.File.IsValidFilename(newName) {\n\t\terr = errors.New(Conf.Language(151))\n\t\treturn\n\t}\n","sourceCodeStart":1478,"sourceCodeEnd":1514,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/assets.go#L1478-L1514","documentation":"Returned by RenameAsset (assets.go:1496) when the resolved absolute path of the asset being renamed belongs to an encrypted notebook (IsEncryptedAssetPath(absPath) is true). Encrypted notebooks incorporate the on-disk asset filename into the AAD (additional authenticated data) of the ciphertext, so renaming would invalidate the authenticated envelope; the kernel refuses rather than re-wrap the key material.","triggerScenarios":"Calling /api/asset/renameAsset with an oldPath that resolves (via GetAssetAbsPathInBox) inside a notebook whose box.conf is encrypted, i.e. an asset stored under an encrypted box's data/<boxid>/assets/ tree. Note the check runs only when GetAssetAbsPathInBox returns no error; if the path cannot be resolved the rename proceeds and fails later.","commonSituations":"User enables notebook encryption then tries to rename an embedded image/PDF from the asset menu; plugin or sync-driven rename targeting an encrypted box; attempting to rename a shared asset referenced from an encrypted notebook.","solutions":["Do not rename assets inside encrypted notebooks from the UI/API; this is an intentional limitation, not a bug.","If a rename is required, move the asset out of the encrypted notebook (or decrypt the notebook temporarily), rename, then re-embed — the filename will then not be part of the AAD.","Verify the target box's encryption status before offering a rename action in the UI so the option is hidden for encrypted boxes."],"exampleFix":"// before: rename offered unconditionally\nmodel.RenameAsset(oldPath, newName)\n\n// after: gate the UI action on encryption status\nabsPath, absErr := model.GetAssetAbsPathInBox(oldPath, \"\")\nif absErr == nil && model.IsEncryptedAssetPath(absPath) {\n    showMessage(window.siyuan.languages[\"renameDisabledEncrypted\"])\n    return\n}\nmodel.RenameAsset(oldPath, newName)","handlingStrategy":"validation","validationCode":"// Hide/disable rename for assets inside encrypted notebooks.\nconst absPath = await getAssetAbsPathInBox(oldPath)\nif (absPath && await isEncryptedAssetPath(absPath)) {\n  // do not offer rename\n  return\n}","typeGuard":null,"tryCatchPattern":"// This is a hard limitation; do not retry, inform the user instead.\ntry { await renameAsset(oldPath, newName) }\ncatch (e) { if (/encrypted notebooks/i.test(e.message)) showInfo(e.message) else throw e }","preventionTips":["Check IsEncryptedAssetPath before exposing the rename affordance in the UI.","Document that encrypted-notebook assets cannot be renamed because the filename is part of the AAD.","To rename, decrypt/move the asset out of the encrypted box first."],"tags":["assets","encryption","rename","notebook","aad"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}