AlistGo/alist · error
baidu youth sk is empty
Error message
baidu youth sk is empty
What it means
Returned by BaiduYouth.getCurrentUserSK (drivers/baidu_youth/util.go:326): both the live getUserSK call and the cached d.sk came back empty (and getUserSK itself reported no error). The sk is the secret key used to compute the rand signature for locatedownload; an empty sk means downloads cannot be signed.
Source
Thrown at drivers/baidu_youth/util.go:326
}
}
func nextDPLogID() string {
return strconv.FormatInt(time.Now().UnixNano(), 10)
}
func (d *BaiduYouth) getCurrentUserSK(ctx context.Context) (string, error) {
sk, err := d.getUserSK(ctx)
if err == nil && sk != "" {
return sk, nil
}
if d.sk != "" {
return d.sk, nil
}
if err != nil {
return "", err
}
return "", fmt.Errorf("baidu youth sk is empty")
}
func (d *BaiduYouth) locatedownloadRand(sk string, nowMilli int64) string {
sum := sha1.Sum([]byte(strconv.FormatInt(d.uk, 10) + sk + strconv.FormatInt(nowMilli, 10) + "0"))
return hex.EncodeToString(sum[:])
}
func (d *BaiduYouth) locatedownloadSign(fileMD5 string, fileID string, nowMilli int64) string {
sum := md5.Sum([]byte(fileMD5 + "_" + strconv.FormatInt(d.uk, 10) + "_" + fileID + "_" + strconv.FormatInt(nowMilli, 10)))
return hex.EncodeToString(sum[:])
}
func (d *BaiduYouth) resolveDownloadMeta(ctx context.Context, file model.Obj) (string, string, string, error) {
parentDir := stdpath.Dir(file.GetPath())
if parentDir == "." {
parentDir = "/"
}
View on GitHub (pinned to 843d9dc814)
Solutions
- Re-init the storage with fresh cookies so the sk fetch runs again during bootstrap
- Verify the sk endpoint (getUserSK) actually returns content with current cookies
- Persist/cache the sk at init time so per-download calls have a fallback
Defensive patterns
Strategy: retry
Try / catch
url, err := d.getLocateDownloadURL(ctx, file)
if err != nil && strings.Contains(err.Error(), "sk is empty") {
if ierr := d.Init(ctx); ierr == nil { // re-bootstrap caches sk
url, err = d.getLocateDownloadURL(ctx, file)
}
} Prevention
- Populate sk during Init so per-download calls have a warm cache
- Refresh cookies at the first sign of auth weirdness — sk, uk and bdstoken expire together
- Do not sign requests with an sk you never verified non-empty
When it happens
Trigger: getLocateDownloadURL -> getCurrentUserSK when the sk API returns an empty-but-successful response and the driver was never initialized with an sk: fresh/expired cookies or a changed API shape.
Common situations: Cookie set valid enough for listing but missing the session state that yields sk; Baidu changed the sk endpoint response; long-lived process whose sk cache never got populated.
Related errors
- failed to get bdstoken from baidu youth cookie
- failed to get uk from baidu youth cookie
- api_key is empty
- cookie is empty
- invalid auth_type
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/3b24a25e99163ef5.
Report an issue: GitHub.