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
- 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
- Refresh credentials / re-auth if the code turns out to be token-related even if the code string differs (keep a mapping table current)
- For rate limits, add backoff before retrying the same request
- 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
- Branch on the RespErr code, not the free-text message — messages change with server locale/wording
- Maintain a code-to-action map and add new codes as Aliyun introduces them
- Wrap pass-through errors with the code for actionable logs
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
- e.Message
- e.Code + ": " + e.Message
- %s
- request failed: %s
- dynamic: fmt.Errorf(info) - message passthrough from API 'in
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/1f9c6ef7e5119b2e.
Report an issue: GitHub.