siyuan-note/siyuan · error
asset path [ ] does not match data path [ ]
Error message
asset path [%s] does not match data path [%s]
What it means
When a dataPath is given, resolveAssetRequestPath derives the canonical asset path from it and requires that it matches the `cleanPath` (the URL path being requested). If the derived asset path differs from the requested path — or AssetPathFromDataRelativePath fails — the request is rejected because the URL and the dataPath point at different files.
Solutions
- Ensure the URL path exactly equals the asset path derived from dataPath (e.g. /assets/foo.png with dataPath=assets/foo.png)
- Fix the dataPath value so it maps to the requested asset
- Drop dataPath and use box-scoped resolution instead if the path is notebook-relative
Example fix
// before
fetchPost("/assets/wrong-name.png?dataPath=assets/foo.png")
// after
fetchPost("/assets/foo.png?dataPath=assets/foo.png") Defensive patterns
Strategy: validation
Validate before calling
const assetPath = "/assets/" + dataPath.replace(/^assets\//, "");
if (cleanPath !== assetPath) throw new Error("URL path and dataPath must match"); Prevention
- Derive the URL path from dataPath with one function, never hand-write both
- Regenerate asset URLs when dataPath values change instead of reusing cached URLs
When it happens
Trigger: Requesting an asset URL whose path does not correspond to the `dataPath` parameter, e.g. `/assets/other.png?dataPath=assets/foo.png`, or passing a dataPath that is not a valid asset-relative path.
Common situations: Stale cached asset URLs paired with an updated dataPath; typos when constructing the URL programmatically; a dataPath pointing into a different assets folder than the URL path.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- box and dataPath cannot be used together
- endpoint does not accept multipart data
- Parses request [ ] failed
- the request body is empty or truncated (EOF)
- Access to encrypted notebook data is not supported via this…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/c96d3a08c6169e0d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/server/serve.go:1097
if err != nil {
return false
}
_, validatedAbsPath, err := model.ResolveDataAssetPath(filepath.ToSlash(dataRelativePath))
return err == nil && filepath.Clean(validatedAbsPath) == filepath.Clean(assetAbsPath)
}
func resolveAssetRequestPath(cleanPath, boxID, dataPath string) (string, error) {
if dataPath != "" {
if boxID != "" {
return "", errors.New("box and dataPath cannot be used together")
}
dataRelativePath, assetAbsPath, err := model.ResolveDataAssetPath(dataPath)
if err != nil {
return "", err
}
assetPath, _, ok := model.AssetPathFromDataRelativePath(dataRelativePath)
if !ok || assetPath != cleanPath {
return "", fmt.Errorf("asset path [%s] does not match data path [%s]", cleanPath, dataPath)
}
return assetAbsPath, nil
}
if boxID != "" {
return model.GetAssetAbsPathInBox(cleanPath, boxID)
}
return model.GetAssetAbsPath(cleanPath)
}
func serveAssets(ginServer *gin.Engine) {
ginServer.POST("/upload", model.CheckAuth, model.CheckAdminRole, model.CheckReadonly, model.Upload)
ginServer.GET("/assets/*path", model.CheckAuth, func(context *gin.Context) {
requestPath := context.Param("path")
if "/" == requestPath || "" == requestPath {
// 禁止访问根目录 Disable HTTP access to the /assets/ path https://github.com/siyuan-note/siyuan/issues/15257
context.Status(http.StatusForbidden)
returnView on GitHub (pinned to 9f775e8a12)