{"record":{"id":"2ac72ee36965310b","repo":"siyuan-note/siyuan","slug":"managed-export-is-unavailable","errorCode":null,"errorMessage":"managed export is unavailable","messagePattern":"managed export is unavailable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/encrypted_export.go","lineNumber":191,"sourceCode":"\t}\n\treturn filepath.FromSlash(strings.Join(parts, \"/\"))\n}\n\n// AcquireExportArtifactLease 为导出产物取得覆盖整个复制过程的生命周期租约。\nfunc AcquireExportArtifactLease(exportPath string) (lease *ExportArtifactLease, err error) {\n\tif after, ok := strings.CutPrefix(exportPath, \"/export/\"); ok {\n\t\tfileName, decodeErr := url.PathUnescape(after)\n\t\tif decodeErr != nil {\n\t\t\treturn nil, decodeErr\n\t\t}\n\t\tfileName = filepath.Clean(fileName)\n\t\tif fileName == \".\" || strings.HasPrefix(fileName, \"..\") || filepath.IsAbs(fileName) {\n\t\t\treturn nil, errors.New(\"invalid export path\")\n\t\t}\n\t\tif IsManagedEncryptedExportPath(fileName) {\n\t\t\tboxID, artifact, resolved := ResolveManagedEncryptedExport(fileName)\n\t\t\tif !resolved {\n\t\t\t\treturn nil, errors.New(\"managed export is unavailable\")\n\t\t\t}\n\t\t\tif err = AcquireEncryptedBoxOperation(boxID); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tHoldBoxReadLock(boxID)\n\t\t\trelease := true\n\t\t\tdefer func() {\n\t\t\t\tif release {\n\t\t\t\t\tReleaseBoxReadLock(boxID)\n\t\t\t\t\tReleaseEncryptedBoxOperation(boxID)\n\t\t\t\t}\n\t\t\t}()\n\t\t\t_, artifact, resolved = ResolveManagedEncryptedExport(fileName)\n\t\t\tif !resolved {\n\t\t\t\treturn nil, errors.New(\"managed export is unavailable\")\n\t\t\t}\n\t\t\tif _, dekErr := GetDEKIfUnlocked(boxID); dekErr != nil {\n\t\t\t\treturn nil, dekErr","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/encrypted_export.go#L173-L209","documentation":"When the requested export file name belongs to a managed encrypted export path, `ResolveManagedEncryptedExport` must map it back to a live box/artifact. This error means the name has the managed prefix but no matching managed export registration exists — the artifact record is gone or was never registered.","triggerScenarios":"AcquireExportArtifactLease called with a managed export path for which ResolveManagedEncryptedExport returns resolved=false (first lookup, before any lease is held).","commonSituations":"Requesting an export lease for an artifact whose registration expired or was cleared after kernel restart; a client retrying with an old managed file name after the export was regenerated; typo'd managed path.","solutions":["Re-run the export to produce a fresh managed export path, then request the lease with the new name.","Verify the source notebook is unlocked — managed resolution requires the box to still be registered.","Clear the stale reference in the client and re-navigate from the export result instead of a cached URL.","If this happens right after restart, re-trigger the export since managed registrations are in-memory."],"exampleFix":"// before\nleaseFromOldManagedName(\"export/managed-abc123.html\") // stale after restart\n// after\nconst exported = await runExport(boxID) // returns fresh managed name\nleaseFromOldManagedName(exported.managedName)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"lease, err := model.AcquireExportArtifactLease(name)\nif err != nil && err.Error() == \"managed export is unavailable\" {\n    // regenerate the export and retry with the fresh managed name\n    fresh := regenerateExport(boxID)\n    lease, err = model.AcquireExportArtifactLease(fresh)\n}","preventionTips":["Treat managed export names as ephemeral; re-export after kernel restart.","Do not cache managed export URLs across sessions.","Avoid re-locking or cleaning exports while clients still hold managed names."],"tags":["go","encryption","export","state"],"backgroundTag":"resource-not-found","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}