{"record":{"id":"1f9c6ef7e5119b2e","repo":"AlistGo/alist","slug":"e-message-1f9c6e","errorCode":null,"errorMessage":"{e.Message}","messagePattern":"\\{e\\.Message\\}","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/aliyundrive/util.go","lineNumber":131,"sourceCode":"\treq.SetError(&e)\n\tres, err := req.Execute(method, url)\n\tif err != nil {\n\t\treturn nil, err, e\n\t}\n\tif e.Code != \"\" {\n\t\tswitch e.Code {\n\t\tcase \"AccessTokenInvalid\":\n\t\t\terr = d.refreshToken()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err, e\n\t\t\t}\n\t\tcase \"DeviceSessionSignatureInvalid\":\n\t\t\terr = d.createSession()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err, e\n\t\t\t}\n\t\tdefault:\n\t\t\treturn nil, errors.New(e.Message), e\n\t\t}\n\t\treturn d.request(url, method, callback, resp)\n\t} else if res.IsError() {\n\t\treturn nil, errors.New(\"bad status code \" + res.Status()), e\n\t}\n\treturn res.Body(), nil, e\n}\n\nfunc (d *AliDrive) getFiles(fileId string) ([]File, error) {\n\tmarker := \"first\"\n\tres := make([]File, 0)\n\tfor marker != \"\" {\n\t\tif marker == \"first\" {\n\t\t\tmarker = \"\"\n\t\t}\n\t\tvar resp Files\n\t\tdata := base.Json{\n\t\t\t\"drive_id\":                d.DriveId,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/aliyundrive/util.go#L113-L149","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ndefault:\n    return nil, errors.New(e.Message), e\n\n// after — keep the code for actionable errors\ndefault:\n    return nil, fmt.Errorf(\"aliyundrive api error %s: %s\", e.Code, e.Message), e","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"// Go\nfunc isAliyundriveApiErr(err error) bool {\n    // request returns (body, err, RespErr); when err != nil and e.Code != \"\"\n    // the message is a passthrough API message\n    return err != nil && e != nil && e.Code != \"\"\n}","tryCatchPattern":"body, err, e := d.request(url, method, cb, resp)\nif err != nil {\n    switch e.Code {\n    case \"NotFound.File\", \"NotFound\":\n        return errs.ObjectNotFound\n    case \"TooManyRequests\":\n        time.Sleep(backoff); // retry once\n    default:\n        return fmt.Errorf(\"aliyundrive %s: %w\", e.Code, err)\n    }\n}","preventionTips":["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"],"tags":["aliyundrive","api-error","passthrough","error-handling"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}