AlistGo/alist · error

failed to get uk from baidu youth cookie

Error message

failed to get uk from baidu youth cookie

What it means

Returned by BaiduYouth's credential bootstrap (drivers/baidu_youth/util.go:210): the account's uk (user id number) could not be determined from cookies or the userinfo response. The uk is used in download signatures (locatedownloadRand/Sign mix in d.uk), so without it no signed download is possible.

Source

Thrown at drivers/baidu_youth/util.go:210

		}
		if uk == 0 {
			uk = int64(utils.Json.Get(body, "result", "uk").ToInt())
		}
		if bdstoken == "" {
			bdstoken = utils.Json.Get(body, "result", "bdstoken").ToString()
		}
		if sk == "" {
			sk = utils.Json.Get(body, "result", "sk").ToString()
		}
	}
	if sk == "" {
		sk, _ = d.getUserSK(ctx)
	}
	if bdstoken == "" {
		return 0, "", "", fmt.Errorf("failed to get bdstoken from baidu youth cookie")
	}
	if uk == 0 {
		return 0, "", "", fmt.Errorf("failed to get uk from baidu youth cookie")
	}
	return uk, bdstoken, sk, nil
}

func (d *BaiduYouth) getFiles(ctx context.Context, dir string) ([]File, error) {
	page := 1
	num := 1000
	params := map[string]string{
		"dir": dir,
	}
	if d.OrderBy != "" {
		params["order"] = d.OrderBy
		if d.OrderDirection == "desc" {
			params["desc"] = "1"
		} else {
			params["desc"] = "0"
		}
	}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Update the full cookie set in storage config (BDUSS + SToken) from a live browser session
  2. Confirm login works and the dashboard loads before copying cookies
  3. If it persists, dump (without secrets) which fields were found to see whether userinfo returned an error body
Defensive patterns

Strategy: validation

Validate before calling

if uk, _, _, err := d.getUserINFO(ctx); err != nil || uk == 0 {
    return fmt.Errorf("baidu_youth cookies invalid (no uk): refresh BDUSS/SToken and re-add the storage")
}

Prevention

When it happens

Trigger: Same bootstrap path as the bdstoken error: userinfo call failed or its JSON lacked the uk field, and no cookie carried it. Typically the whole cookie set is invalid or expired, so every extraction comes back empty.

Common situations: Expired BDUSS; only a session cookie pasted without the full set; account-level API changes.

Related errors


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