AlistGo/alist · error

file share does not support nested path

Error message

file share does not support nested path

What it means

Returned by resolveShareTarget (server/handles/share.go:363) when a share whose target is a single file (share.IsDir == false) is requested with any relative path other than "/". A file share exposes exactly one resource — its root — so nested sub-paths have no meaning and are rejected before any filesystem access.

Source

Thrown at server/handles/share.go:363

	if token == "" {
		common.ErrorStrResp(c, "share password required", 401)
		return false
	}
	if err := shareauth.VerifyAccess(share, token); err != nil {
		common.ErrorResp(c, err, 401)
		return false
	}
	return true
}

func shouldTrackShareContentAccess(c *gin.Context) bool {
	return c.Request.Method != http.MethodHead
}

func resolveShareTarget(share *model.Share, rawRelPath string) (string, string, error) {
	cleanRelPath := utils.FixAndCleanPath(rawRelPath)
	if !share.IsDir && cleanRelPath != "/" {
		return "", "", fmt.Errorf("file share does not support nested path")
	}
	if cleanRelPath == "/" {
		return share.RootPath, "/", nil
	}
	target := utils.FixAndCleanPath(stdpath.Join(share.RootPath, cleanRelPath))
	if !utils.IsSubPath(share.RootPath, target) {
		return "", "", fmt.Errorf("share path out of range")
	}
	return target, cleanRelPath, nil
}

func resolveShareWildcardTarget(share *model.Share, rawPath string) (string, string, error) {
	path, err := url.PathUnescape(rawPath)
	if err != nil {
		return "", "", err
	}
	return resolveShareTarget(share, strings.TrimPrefix(path, "/"))
}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Request the share root only (relative path "/") for file shares
  2. If nested paths must work, share the parent directory instead of the single file
  3. Branch client logic on the share's is_dir flag before building the path

Example fix

// before
url := fmt.Sprintf("/s/%s/report.pdf", shareID) // file share
// after
url := fmt.Sprintf("/s/%s", shareID) // file share serves its root
Defensive patterns

Strategy: validation

Validate before calling

func sharePathAllowed(isDir bool, relPath string) bool {
  cleaned := path.Clean("/" + relPath)
  return isDir || cleaned == "/"
}

Prevention

When it happens

Trigger: GET on a file share's content endpoint with a URL like /s/<shareID>/extra/segment or a wildcard path resolving below the file; clients that build share URLs by appending a filename to the share root.

Common situations: Generic download helpers that always append a filename to a base URL; resuming tools that reconstruct paths; sharing a file when the client assumed a directory share.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/ada77730315014b8. Report an issue: GitHub.