AlistGo/alist · warning

baidu youth locatedownload url is empty

Error message

baidu youth locatedownload url is empty

What it means

Defensive check in normalizeLocatedownloadURL (drivers/baidu_youth/util.go:364): it refuses to process an empty URL string. It only fires if a caller passes '' — the upstream callers (getLocatedownloadURL) already check resp.URL themselves, so seeing it means an internal contract violation or a new call path skipping the check.

Source

Thrown at drivers/baidu_youth/util.go:364

	if err != nil {
		return "", "", "", err
	}
	for _, listedFile := range files {
		if listedFile.Path != file.GetPath() {
			continue
		}
		fileID := strconv.FormatInt(listedFile.FsId, 10)
		if listedFile.Path != "" && fileID != "" && listedFile.Md5 != "" {
			return listedFile.Path, fileID, listedFile.Md5, nil
		}
		return "", "", "", fmt.Errorf("baidu youth list metadata incomplete for %s", file.GetPath())
	}
	return "", "", "", errs.NewErr(errs.ObjectNotFound, "baidu youth list metadata not found: %s", file.GetPath())
}

func normalizeLocatedownloadURL(rawURL string) (string, error) {
	if rawURL == "" {
		return "", fmt.Errorf("baidu youth locatedownload url is empty")
	}
	if !strings.Contains(rawURL, "response-cache-control=") {
		sep := "&"
		if !strings.Contains(rawURL, "?") {
			sep = "?"
		}
		rawURL += sep + "response-cache-control=private"
	}
	return rawURL, nil
}

func (d *BaiduYouth) getMediaInfoDLink(ctx context.Context, file model.Obj) (string, error) {
	path, fileID, _, err := d.resolveDownloadMeta(ctx, file)
	if err != nil {
		return "", err
	}

	var resp MediaInfoResp

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Check the URL is non-empty at the source (right after the API response) before normalizing
  2. Reuse getLocateDownloadURL, which performs the empty check on resp.URL, instead of calling the normalizer directly
Defensive patterns

Strategy: validation

Validate before calling

if rawURL == "" {
    return "", fmt.Errorf("locatedownload returned no url for %s", file.GetPath())
}
return normalizeLocatedownloadURL(rawURL)

Prevention

When it happens

Trigger: Directly calling normalizeLocatedownloadURL with an empty string; a future code path obtaining the URL from a different API that returned an empty field without checking first.

Common situations: Refactors adding new download URL sources; unit tests exercising the normalizer with zero values.

Related errors


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