{"record":{"id":"5207dcbac3fa9695","repo":"siyuan-note/siyuan","slug":"box-and-datapath-cannot-be-used-together","errorCode":null,"errorMessage":"box and dataPath cannot be used together","messagePattern":"box and dataPath cannot be used together","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"kernel/server/serve.go","lineNumber":1089,"sourceCode":"\t\t}\n\t\treturn gulu.File.IsSubPath(filepath.Join(util.DataDir, requestBoxID, \"assets\"), assetAbsPath)\n\t}\n\n\tif model.IsEncryptedAssetPath(assetAbsPath) {\n\t\treturn false\n\t}\n\tdataRelativePath, err := filepath.Rel(util.DataDir, assetAbsPath)\n\tif err != nil {\n\t\treturn false\n\t}\n\t_, validatedAbsPath, err := model.ResolveDataAssetPath(filepath.ToSlash(dataRelativePath))\n\treturn err == nil && filepath.Clean(validatedAbsPath) == filepath.Clean(assetAbsPath)\n}\n\nfunc resolveAssetRequestPath(cleanPath, boxID, dataPath string) (string, error) {\n\tif dataPath != \"\" {\n\t\tif boxID != \"\" {\n\t\t\treturn \"\", errors.New(\"box and dataPath cannot be used together\")\n\t\t}\n\t\tdataRelativePath, assetAbsPath, err := model.ResolveDataAssetPath(dataPath)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tassetPath, _, ok := model.AssetPathFromDataRelativePath(dataRelativePath)\n\t\tif !ok || assetPath != cleanPath {\n\t\t\treturn \"\", fmt.Errorf(\"asset path [%s] does not match data path [%s]\", cleanPath, dataPath)\n\t\t}\n\t\treturn assetAbsPath, nil\n\t}\n\tif boxID != \"\" {\n\t\treturn model.GetAssetAbsPathInBox(cleanPath, boxID)\n\t}\n\treturn model.GetAssetAbsPath(cleanPath)\n}\n\nfunc serveAssets(ginServer *gin.Engine) {","sourceCodeStart":1071,"sourceCodeEnd":1107,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/server/serve.go#L1071-L1107","documentation":"resolveAssetRequestPath resolves the absolute path of an asset requested from the HTTP server. When the request supplies both a box ID and a dataPath, the two resolution modes are mutually exclusive, so the function rejects the request with this error rather than guessing which one to honor.","triggerScenarios":"Calling the asset-serving endpoint (which routes through resolveAssetRequestPath) with both a non-empty `box` query parameter and a non-empty `dataPath` query parameter.","commonSituations":"Frontend code or plugins that switched from box-scoped asset lookups to the dataPath-based asset URL but left the old `box` parameter in the query string; hand-built URLs combining both params.","solutions":["Remove the `box` parameter from the request when a `dataPath` is supplied (dataPath resolution is workspace-wide)","Remove the `dataPath` parameter and keep only `box` if the asset lives inside a specific notebook","Update client code to build only one style of asset URL"],"exampleFix":"// before\nfetchPost(\"/assets/foo.png?box=20240101120000-abcdefg&dataPath=assets/foo.png\")\n// after\nfetchPost(\"/assets/foo.png?dataPath=assets/foo.png\")","handlingStrategy":"validation","validationCode":"if (box && dataPath) throw new Error(\"Pass either box or dataPath, not both\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build asset URLs from a single helper that only ever sets one of box/dataPath","When migrating to dataPath URLs, delete the box parameter, don't append next to it"],"tags":["http","api","mutually-exclusive-parameters"],"backgroundTag":"mutually-exclusive-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"}