AlistGo/alist · warning
invalid auth_type
Error message
invalid auth_type
What it means
Thrown by Yunpan360 Init()'s switch default when d.authMode() returns something other than "api_key" or "cookie". In the current code this is effectively unreachable: Init lowercases and defaults an empty AuthType to cookie, and authMode() returns api_key only when AuthType=="api_key", cookie otherwise. It is a defensive guard against future auth modes or a corrupted AuthType value (e.g. injected mid-struct without going through Init normalization).
Source
Thrown at drivers/yunpan360/driver.go:87
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 {
d.cachedOpenAuth = nil
d.openAuthExpire = time.Time{}
d.cachedCookieSession = nil
d.cookieSessionExpire = time.Time{}
return nil
}
func (d *Yunpan360) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) {
dirPath := dir.GetPath()
if dirPath == "" {
dirPath = d.RootFolderPath
}
objs := make([]model.Obj, 0, d.PageSize)View on GitHub (pinned to 843d9dc814)
Solutions
- Set auth_type to exactly "cookie" or "api_key" (the values in meta.go options) and re-init
- If constructing the driver in code, go through Init() so empty/odd values get normalized
- On a fork adding a new auth mode, add the matching case to this switch
Defensive patterns
Strategy: validation
Validate before calling
t := strings.ToLower(strings.TrimSpace(cfg.AuthType))
if t != "" && t != "cookie" && t != "api_key" {
return fmt.Errorf("auth_type must be cookie or api_key, got %q", cfg.AuthType)
} Prevention
- Restrict auth_type to the two documented options
- Construct the driver through Init() so values get normalized
- On forks adding auth modes, extend the driver switch
When it happens
Trigger: Calling driver methods on a Yunpan360 instance whose AuthType was set directly to an unrecognized value without running Init(); a future driver version adds a third auth mode but this switch wasn't updated.
Common situations: Programmatic use of the driver outside AList's config flow; hand-crafted driver structs in tests; merged configs from a forked driver exposing extra auth types.
Related errors
- api_key is empty
- cookie is empty
- yunpan auth failed: errno=%d
- access token is empty
- refresh_token is empty
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/58b03363f26204f3.
Report an issue: GitHub.