{"record":{"id":"68e1ed0947bd9d3b","repo":"AlistGo/alist","slug":"errno-d-refer-to-https-photo-baidu-com-union","errorCode":null,"errorMessage":"errno: %d, refer to https://photo.baidu.com/union/doc","messagePattern":"errno: (.+?), refer to https://photo\\.baidu\\.com/union/doc","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/baidu_photo/utils.go","lineNumber":56,"sourceCode":"\t\treturn nil, err\n\t}\n\n\terron := utils.Json.Get(res.Body(), \"errno\").ToInt()\n\tswitch erron {\n\tcase 0:\n\t\tbreak\n\tcase 50805:\n\t\treturn nil, fmt.Errorf(\"you have joined album\")\n\tcase 50820:\n\t\treturn nil, fmt.Errorf(\"no shared albums found\")\n\tcase 50100:\n\t\treturn nil, fmt.Errorf(\"illegal title, only supports 50 characters\")\n\t// case -6:\n\t// \tif err = d.refreshToken(); err != nil {\n\t// \t\treturn nil, err\n\t// \t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"errno: %d, refer to https://photo.baidu.com/union/doc\", erron)\n\t}\n\treturn res, nil\n}\n\n//func (d *BaiduPhoto) Request(furl string, method string, callback base.ReqCallback, resp interface{}) ([]byte, error) {\n//\tres, err := d.request(furl, method, callback, resp)\n//\tif err != nil {\n//\t\treturn nil, err\n//\t}\n//\treturn res.Body(), nil\n//}\n\n// func (d *BaiduPhoto) refreshToken() error {\n// \tu := \"https://openapi.baidu.com/oauth/2.0/token\"\n// \tvar resp base.TokenResp\n// \tvar e TokenErrResp\n// \t_, err := base.RestyClient.R().SetResult(&resp).SetError(&e).SetQueryParams(map[string]string{\n// \t\t\"grant_type\":    \"refresh_token\",","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/baidu_photo/utils.go#L38-L74","documentation":"Catch-all in BaiduPhoto.Request (drivers/baidu_photo/utils.go:56): any union API errno not explicitly mapped (50805/50820/50100) is wrapped as 'errno: %d, refer to https://photo.baidu.com/union/doc'. It preserves the numeric code so the developer can look up the exact cause in Baidu's official union doc. Common unmapped codes include -6 (identity/token expired, whose refresh branch is commented out in the source) and various rate-limit codes.","triggerScenarios":"Any BaiduPhoto Request/Get/Post whose JSON body carries a non-zero errno outside the three mapped cases: expired access_token (errno -6), rate limiting, invalid parameters, backend quota errors.","commonSituations":"Long-running mounts whose token expired; concurrent requests triggering rate limits; API changes on Baidu's side introducing new errno values.","solutions":["Look up the numeric errno at https://photo.baidu.com/union/doc to get the authoritative cause","For errno -6, refresh the access_token (re-init the driver / update credentials) and retry","Add rate-limit backoff if the code appears under concurrency","Add an explicit case in the switch for recurring codes so they get actionable messages"],"exampleFix":"// before\ndefault:\n    return nil, fmt.Errorf(\"errno: %d, refer to https://photo.baidu.com/union/doc\", erron)\n\n// after (map the recurring code explicitly, and revive token refresh)\ncase -6:\n    if err := d.refreshToken(); err != nil {\n        return nil, err\n    }\n    return d.Request(client, furl, method, callback, resp) // one retry\ndefault:\n    return nil, fmt.Errorf(\"errno: %d, refer to https://photo.baidu.com/union/doc\", erron)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := d.Request(client, furl, method, callback, resp)\nif err != nil {\n    var errno int\n    if _, e := fmt.Sscanf(err.Error(), \"errno: %d\", &errno); e == nil {\n        switch errno {\n        case -6: // token expired -> refresh once, then retry once\n            if rerr := d.refreshToken(); rerr != nil {\n                return nil, rerr\n            }\n            return d.Request(client, furl, method, callback, resp)\n        }\n    }\n}\nreturn res, err","preventionTips":["Keep the errno number from the message and check https://photo.baidu.com/union/doc before guessing","Proactively refresh tokens on a schedule shorter than their lifetime","Log full request context (endpoint, errno) when this fires — the doc lookup needs the code"],"tags":["baidu-photo","api","errno","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}