AlistGo/alist · error

yunpan upload request failed: status=%d body=%s

Error message

yunpan upload request failed: status=%d body=%s

What it means

Thrown by yunpan360's upload HTTP layer when the raw response status is >= 400 (http.StatusBadRequest). Unlike the envelope-decoded errors, this means the transport-level request itself was rejected by www.yunpan.com — auth cookie missing, URL wrong, body malformed, or server-side 5xx — with the response body included verbatim for diagnosis.

Source

Thrown at drivers/yunpan360/upload.go:625

	if accessToken != "" {
		req.Header.Set("Access-Token", accessToken)
	}
	if contentType != "" {
		req.Header.Set("Content-Type", contentType)
	}

	resp, err := base.HttpClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	respBody, err := io.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	if resp.StatusCode >= http.StatusBadRequest {
		return fmt.Errorf("yunpan upload request failed: status=%d body=%s", resp.StatusCode, strings.TrimSpace(string(respBody)))
	}
	return decodeUploadResp(respBody, out)
}

func decodeUploadResp(body []byte, out interface{}) error {
	var env uploadEnvelope
	if err := utils.Json.Unmarshal(body, &env); err != nil {
		return err
	}
	if env.Errno != nil && *env.Errno != 0 {
		if env.Errmsg == "" {
			return fmt.Errorf("yunpan upload request failed: errno=%d", *env.Errno)
		}
		return errors.New(env.Errmsg)
	}
	if env.Errno == nil && strings.TrimSpace(env.Errmsg) != "" && len(env.Data) > 0 && string(env.Data) == "[]" {
		return errors.New(env.Errmsg)
	}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Refresh the Cookie credential in driver storage and retry the upload
  2. Log the status code: 401/403 → re-auth, 5xx → retry with backoff, 400 → inspect body for the parameter at fault
  3. Re-acquire the upload URL/token immediately before the transfer if the flow caches it
  4. Ensure required headers (Referer https://www.yunpan.com, Origin, X-Requested-With) are present on the request
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(d.Cookie) == "" {
    return errors.New("yunpan360: cookie credential missing; update driver storage")
}
if req.ContentLength < 0 {
    return errors.New("yunpan360: request body length unknown; buffer file first")
}

Try / catch

respBody, err := doUpload(req)
if err != nil {
    if strings.Contains(err.Error(), "status=401") || strings.Contains(err.Error(), "status=403") {
        return fmt.Errorf("yunpan360 session invalid, update cookie: %w", err)
    }
    if strings.Contains(err.Error(), "status=5") { // 5xx: retry with backoff
        time.Sleep(3 * time.Second)
        return doUpload(rebuildUploadRequest())
    }
    return err
}

Prevention

When it happens

Trigger: Expired or missing Cookie header (d.Cookie empty/stale) yielding 401/403; uploading with a Content-Length mismatch yielding 400; server maintenance returning 5xx; WAF blocking the client (missing Referer/Origin headers); upload URL one-time token already consumed.

Common situations: Cookie-based auth where the session expired (user must re-paste cookie); long uploads where the pre-fetched upload URL expired; egress IP flagged by 360's WAF; file larger than the endpoint allows.

Related errors


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