{"record":{"id":"a634c7977a305b6a","repo":"siyuan-note/siyuan","slug":"unsupported-export-path","errorCode":null,"errorMessage":"unsupported export path","messagePattern":"unsupported export path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/encrypted_export.go","lineNumber":225,"sourceCode":"\t\t\t}\n\t\t\tif _, dekErr := GetDEKIfUnlocked(boxID); dekErr != nil {\n\t\t\t\treturn nil, dekErr\n\t\t\t}\n\t\t\tlease, err = registerMobileExportLease(boxID, artifact, filepath.Base(fileName), \"\")\n\t\t\tif err == nil {\n\t\t\t\trelease = false\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tartifact := filepath.Join(util.TempDir, \"export\", fileName)\n\t\tif !gulu.File.IsSubPath(filepath.Join(util.TempDir, \"export\"), artifact) {\n\t\t\treturn nil, errors.New(\"export path is outside export directory\")\n\t\t}\n\t\treturn registerMobileExportLease(\"\", artifact, filepath.Base(fileName), \"\")\n\t}\n\n\tif !strings.HasPrefix(exportPath, \"assets/\") {\n\t\treturn nil, errors.New(\"unsupported export path\")\n\t}\n\trelativePath, boxID, parseErr := assetPathAndBox(exportPath, \"\")\n\tif parseErr != nil {\n\t\treturn nil, parseErr\n\t}\n\tif boxID == \"\" || !IsEncryptedBox(boxID) {\n\t\tartifact, resolveErr := GetAssetAbsPath(relativePath)\n\t\tif resolveErr != nil {\n\t\t\treturn nil, resolveErr\n\t\t}\n\t\tif ensureErr := EnsureAssetLocal(artifact); ensureErr != nil {\n\t\t\treturn nil, ensureErr\n\t\t}\n\t\treturn registerMobileExportLease(\"\", artifact, filepath.Base(artifact), \"\")\n\t}\n\tif !IsBoxUnlocked(boxID) {\n\t\treturn nil, errors.New(Conf.Language(314))\n\t}","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/encrypted_export.go#L207-L243","documentation":"AcquireExportArtifactLease only accepts two path shapes: \"/export/<name>\" (temp export artifacts) and \"assets/<path>\" (notebook assets). Any other prefix — empty string, \"/\", \"temp/\", a full URL, an absolute filesystem path — is rejected up front because no lease can be issued for it. The assets/ branch then additionally requires the asset to belong to an encrypted box (otherwise it is resolved as a plain asset).","triggerScenarios":"AcquireExportArtifactLease (via materializeExportArtifact or AcquireMobileExportLease) called with a path that neither starts with \"/export/\" nor \"assets/\" — e.g. \"\", \"/assets/x\", \"assets\" (no trailing slash content is fine, but \"export/foo\" or \"temp/export/foo\" is not), a full \"http://host/export/..\" URL, or an OS absolute path.","commonSituations":"Caller passing an absolute server URL instead of the kernel-relative path; stripping or doubling the leading slash so \"/assets/...\" no longer matches; using the temp-dir filesystem path (\"/tmp/siyuan/export/x.pdf\") instead of the \"/export/x.pdf\" form; plugin/mobile code written against an older path convention.","solutions":["Normalize the input to one of the two supported forms: \"/export/<relative-name>\" or \"assets/<relative-path>\" before calling","If you have an absolute temp path, convert it to \"/export/\" + relative portion; if you have a URL, extract only the path component and drop the scheme/host","For assets, keep the exact \"assets/\" prefix (lowercase, no leading slash) as produced by assetPathAndBox-compatible paths","Log the exact exportPath argument; a mismatch is almost always a slash/scheme normalization bug at the call site"],"exampleFix":"// before\nlease, err := model.AcquireExportArtifactLease(\"/tmp/siyuan/export/doc.pdf\")\n// after\nrel, _ := filepath.Rel(util.TempDir, p)\nlease, err := model.AcquireExportArtifactLease(\"/export/\" + filepath.ToSlash(rel))","handlingStrategy":"validation","validationCode":"function isSupportedLeasePath(p) {\n  return typeof p === \"string\" &&\n    (p.startsWith(\"/export/\") || p.startsWith(\"assets/\"));\n}","typeGuard":null,"tryCatchPattern":"if (!isSupportedLeasePath(exportPath)) {\n  exportPath = normalizeToLeasePath(exportPath); // map URLs/abs paths to \"/export/..\" or \"assets/..\"\n}\ntry {\n  lease = await acquireExportArtifactLease(exportPath);\n} catch (e) {\n  if (String(e).includes(\"unsupported export path\")) throw new Error(`Bad lease path: ${exportPath}`);\n  throw e;\n}","preventionTips":["Keep a single helper that produces lease paths so all call sites use \"/export/...\" or \"assets/...\" consistently","Strip scheme/host from URLs and convert absolute temp paths to relative before calling","Watch slash handling: \"assets/\" (no leading slash) vs \"/export/\" (leading slash) — the two forms differ","Assert path shape in tests for any new caller of AcquireExportArtifactLease"],"tags":["validation","invalid-argument","export","path-format"],"backgroundTag":"invalid-argument-format","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"}