AlistGo/alist · error
api_key is empty
Error message
api_key is empty
What it means
Thrown by Yunpan360 Init() when auth_type is set to "api_key" but the api_key field is blank after trimming. The driver immediately needs the API key to call openUserInfo (open API auth + validation), so an empty key cannot proceed. Configuration is trimmed first, so a whitespace-only value also triggers this.
Source
Thrown at drivers/yunpan360/driver.go:73
d.SubChannel = defaultSubChannel
}
d.EcsEnv = strings.ToLower(strings.TrimSpace(d.EcsEnv))
if d.EcsEnv == "" {
d.EcsEnv = openEnvProd
}
d.Cookie = strings.TrimSpace(d.Cookie)
d.APIKey = strings.TrimSpace(d.APIKey)
d.OwnerQID = strings.TrimSpace(d.OwnerQID)
d.DownloadToken = strings.TrimSpace(d.DownloadToken)
d.cachedOpenAuth = nil
d.openAuthExpire = time.Time{}
d.cachedCookieSession = nil
d.cookieSessionExpire = time.Time{}
switch d.authMode() {
case authTypeAPIKey:
if d.APIKey == "" {
return errors.New("api_key is empty")
}
_, err := d.openUserInfo(ctx)
return err
case authTypeCookie:
if d.Cookie == "" {
return errors.New("cookie is empty")
}
// Web download URLs require browser-session headers; force local proxying
// so AList can forward Referer/Origin instead of exposing a bare 302 URL.
d.WebProxy = true
_, err := d.listCookiePage(ctx, d.RootFolderPath, 0, 1)
return err
default:
return errors.New("invalid auth_type")
}
}
func (d *Yunpan360) Drop(ctx context.Context) error {View on GitHub (pinned to 843d9dc814)
Solutions
- Set the api_key field in the yunpan360 storage config to the key obtained from 360's open API
- If you meant to use browser-cookie auth, set auth_type back to "cookie" and fill cookie instead
- Re-save the storage config after editing so Init() runs again
Defensive patterns
Strategy: validation
Validate before calling
if cfg.AuthType == "api_key" && strings.TrimSpace(cfg.APIKey) == "" {
return errors.New("auth_type=api_key requires a non-empty api_key")
} Prevention
- Validate config completeness before saving the storage
- When switching auth modes, clear or fill the matching credential field
- Treat whitespace-only keys as empty (the driver trims)
When it happens
Trigger: Storage config with auth_type="api_key" and an empty/whitespace api_key field; the key was cleared during a config edit or never filled when switching from cookie to api_key mode.
Common situations: Switching auth modes in the AList admin UI without filling the new credential; automation/terraform that templates the driver config and omits api_key; trailing spaces that were assumed to be the problem but the field is genuinely empty.
Related errors
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/99a1a361456c7757.
Report an issue: GitHub.