AlistGo/alist · error

failed to parse cookie download session from page

Error message

failed to parse cookie download session from page

What it means

getCookieDownloadSessionFromPage fetched the yunpan360 index HTML page successfully, but parseCookieDownloadSessionFromText could not extract the (owner_qid, download_token) session data embedded in it (drivers/yunpan360/util.go:514). This is a scraping failure, not an HTTP failure.

Source

Thrown at drivers/yunpan360/util.go:514

	pageSession, err := d.getCookieDownloadSessionFromPage(ctx)
	if err == nil && pageSession != nil {
		ownerQID = firstNonEmpty(ownerQID, pageSession.OwnerQID)
	}
	if ownerQID == "" {
		return "", errors.New("missing owner_qid for cookie mode")
	}
	return ownerQID, nil
}

func (d *Yunpan360) getCookieDownloadSessionFromPage(ctx context.Context) (*CookieDownloadSession, error) {
	body, err := d.cookiePage(ctx, indexPath)
	if err != nil {
		return nil, err
	}
	session := parseCookieDownloadSessionFromText(string(body))
	if session == nil {
		return nil, errors.New("failed to parse cookie download session from page")
	}
	d.cacheCookieSession(session)
	return session, nil
}

func (d *Yunpan360) getCachedCookieDownloadSession() *CookieDownloadSession {
	d.authMu.Lock()
	defer d.authMu.Unlock()

	if d.cachedCookieSession == nil || time.Now().After(d.cookieSessionExpire) {
		return nil
	}
	session := *d.cachedCookieSession
	return &session
}

func (d *Yunpan360) cacheCookieDownloadSession(ownerQID, token string) {
	d.cacheCookieSession(&CookieDownloadSession{

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Refresh the cookie in storage config with a fresh browser session and retry
  2. Open yunpan360.com in the browser with the same cookie and confirm the download page renders normally (no captcha/login)
  3. Check for driver updates — page-format changes require a parser fix in the driver
  4. Capture the page (d.cookiePage output) and compare its structure with what parseCookieDownloadSessionFromText expects

Example fix

// before: stale cookie yields login page, parser returns nil
session, err := d.getCookieDownloadSessionFromPage(ctx)

// after: refresh cookie first, then scrape
// storage.Setting("cookie", freshCookie)
session, err := d.getCookieDownloadSessionFromPage(ctx)
Defensive patterns

Strategy: fallback

Type guard

func isScrapeFailure(err error) bool { return err != nil && strings.Contains(err.Error(), "parse cookie download session") }

Try / catch

session, err := d.getCookieDownloadSessionFromPage(ctx)
if err != nil {
    // fall back to cached/config values if available
    if s := d.getCachedCookieSession(); s != nil { session = s } else { return nil, err }
}

Prevention

When it happens

Trigger: The driver requests indexPath and the returned HTML no longer matches the patterns the parser expects — e.g. 360 redesigned the page, the page returned a login/redirect page because the cookie is invalid, or the page is region-gated/anti-bot content.

Common situations: Expired cookie making the index page redirect to a login page; 360 frontend deploy changes variable names in the inline JS that holds the session; accessing from an IP/region where a captcha page is served instead.

Understand the failure class

Related errors


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