AlistGo/alist · error

{e.Message}

Error message

{e.Message}

What it means

Returned by AliDrive.request when the Aliyun Drive API responds with an error payload whose e.Code is NOT one of the two auto-recoverable codes (AccessTokenInvalid triggers refresh, DeviceSessionSignatureInvalid triggers createSession). The raw e.Message from the API is passed through as the Go error string — this is a catch-all for unmapped API error codes.

Source

Thrown at drivers/aliyundrive/util.go:131

	req.SetError(&e)
	res, err := req.Execute(method, url)
	if err != nil {
		return nil, err, e
	}
	if e.Code != "" {
		switch e.Code {
		case "AccessTokenInvalid":
			err = d.refreshToken()
			if err != nil {
				return nil, err, e
			}
		case "DeviceSessionSignatureInvalid":
			err = d.createSession()
			if err != nil {
				return nil, err, e
			}
		default:
			return nil, errors.New(e.Message), e
		}
		return d.request(url, method, callback, resp)
	} else if res.IsError() {
		return nil, errors.New("bad status code " + res.Status()), e
	}
	return res.Body(), nil, e
}

func (d *AliDrive) getFiles(fileId string) ([]File, error) {
	marker := "first"
	res := make([]File, 0)
	for marker != "" {
		if marker == "first" {
			marker = ""
		}
		var resp Files
		data := base.Json{
			"drive_id":                d.DriveId,

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Log/inspect the accompanying RespErr code (the code is carried in the third return value `e`) to identify the true API error and act on it
  2. Refresh credentials / re-auth if the code turns out to be token-related even if the code string differs (keep a mapping table current)
  3. For rate limits, add backoff before retrying the same request
  4. Update the driver or map the new code in the switch if a newly introduced API code needs dedicated handling

Example fix

// before
default:
    return nil, errors.New(e.Message), e

// after — keep the code for actionable errors
default:
    return nil, fmt.Errorf("aliyundrive api error %s: %s", e.Code, e.Message), e
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

// Go
func isAliyundriveApiErr(err error) bool {
    // request returns (body, err, RespErr); when err != nil and e.Code != ""
    // the message is a passthrough API message
    return err != nil && e != nil && e.Code != ""
}

Try / catch

body, err, e := d.request(url, method, cb, resp)
if err != nil {
    switch e.Code {
    case "NotFound.File", "NotFound":
        return errs.ObjectNotFound
    case "TooManyRequests":
        time.Sleep(backoff); // retry once
    default:
        return fmt.Errorf("aliyundrive %s: %w", e.Code, err)
    }
}

Prevention

When it happens

Trigger: Any API call whose response error code falls outside {AccessTokenInvalid, DeviceSessionSignatureInvalid}: e.g. NotFound.File, PermissionDenied, TooManyRequests, InvalidParameter, AccountSuspended — after a retry-with-new-session attempt or directly on first response.

Common situations: Aliyun-side error code additions after an API revision (unmapped new codes); expired/deleted files returning NotFound codes; rate-limit bursts; account restrictions; sharing-link permission errors. Because the message is verbatim API text, users see the server's wording with no driver context.

Related errors


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