AlistGo/alist · error

env.Errmsg

Error message

env.Errmsg

What it means

This is decodeUploadResp propagating the 360 upload API's own error message: the response envelope has errno != 0 and a non-empty errmsg, so errors.New(env.Errmsg) returns the server text verbatim (e.g. "文件名已存在" or session-expired messages). It is the standard hard-failure path — the server explicitly rejected the upload request.

Source

Thrown at drivers/yunpan360/upload.go:639

	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)
	}
	if out == nil {
		return nil
	}
	if err := utils.Json.Unmarshal(body, out); err != nil {
		if strings.TrimSpace(env.Errmsg) != "" {
			return errors.New(env.Errmsg)
		}
		return err
	}
	return nil
}

type multipartFile struct {
	FieldName   string

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Read the errmsg text — it states the exact server-side rejection reason
  2. For quota: free space on yunpan.360.cn or delete duplicate files
  3. For auth errors: refresh the api_key/session and re-save the storage config
  4. For rate limits: space out concurrent uploads
Defensive patterns

Strategy: try-catch

Try / catch

err := d.Put(ctx, dstDir, file, up)
if err != nil {
    msg := err.Error()
    switch {
    case strings.Contains(msg, "存在") || strings.Contains(msg, "exist"): // duplicate
        // rename or enable overwrite strategy
    case strings.Contains(msg, "空间") || strings.Contains(msg, "space"): // quota
        return fmt.Errorf("yunpan360 quota exceeded: %w", err)
    default:
        return err
    }
}

Prevention

When it happens

Trigger: Any yunpan360 upload request whose JSON response has a non-zero errno with errmsg: duplicate filename, insufficient quota, invalid/expired auth (qid/token), disallowed file type, or rate limiting from the open API.

Common situations: Uploading a file that already exists where overwrite isn't permitted; storage quota full; api_key credentials revoked or expired; hammering the upload endpoint and getting throttled.

Related errors


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