{"record":{"id":"7498ee21b56dee13","repo":"lyswhut/lx-music-desktop","slug":"error-7498ee","errorCode":null,"errorMessage":"获取热门评论失败","messagePattern":"获取热门评论失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/utils/musicSdk/tx/comment.js","lineNumber":185,"sourceCode":"            BizId: String(songId),\n            LastCommentSeqNo: '',\n            PageSize: limit,\n            PageNum: page - 1,\n            HotType: 1,\n            WithAirborne: 0,\n            PicEnable: 1,\n          },\n        },\n      },\n      headers: {\n        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.0.0',\n        referer: 'https://y.qq.com/',\n        origin: 'https://y.qq.com',\n      },\n    })\n    const { body, statusCode } = await _requestObj2.promise\n    // console.log('body', body)\n    if (statusCode != 200 || body.code !== 0 || body.req.code !== 0) throw new Error('获取热门评论失败')\n    const comment = body.req.data.CommentList\n    return {\n      source: 'tx',\n      comments: this.filterHotComment(comment.Comments),\n      total: comment.Total,\n      page,\n      limit,\n      maxPage: Math.ceil(comment.Total / limit) || 1,\n    }\n  },\n  filterNewComment(rawList) {\n    return rawList.map(item => {\n      let time = this.formatTime(item.time)\n      let timeStr = time ? dateFormat2(time) : null\n      if (item.middlecommentcontent) {\n        let firstItem = item.middlecommentcontent[0]\n        firstItem.avatarurl = item.avatarurl\n        firstItem.praisenum = item.praisenum","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/lyswhut/lx-music-desktop/blob/9c364b482e5621a1d38b50e8610d2fb974457e6e/src/renderer/utils/musicSdk/tx/comment.js#L167-L203","documentation":"Thrown by QQ Music's getHotComment when the newer musicu.fcg endpoint at https://u.y.qq.com/cgi-bin/musicu.fcg returns non-200, body.code !== 0, OR body.req.code !== 0. This is the only error with a double-nested code check (both the outer envelope and the inner req object must report success). Uses HTTPS and a POST with a JSON body (module: music.globalComment.CommentRead, method: GetHotCommentList). Reads body.req.data.CommentList.","triggerScenarios":"Calling getHotComment(mInfo, page, limit) where the outer envelope succeeds (body.code === 0) but the inner request fails (body.req.code !== 0), or vice versa. Tencent changes the module/method path. The song has no hot comments. Rate-limiting or anti-bot detection rejects the request at either layer.","commonSituations":"Tencent's musicu.fcg is an anti-scraping endpoint that frequently changes its module/method contract. The inner req.code may be non-zero for geo-restricted or removed songs. The Chrome/Edge User-Agent string may be flagged and blocked by Tencent's bot detection over time.","solutions":["Log body.code, body.req.code, and statusCode separately to identify which layer failed.","Update the module/method strings to match the current QQ Music web client by inspecting y.qq.com network traffic.","Update the User-Agent string periodically to match current Chrome/Edge versions.","Retry with backoff for transient failures.","Fall back to the legacy fcg_global_comment endpoint if musicu.fcg is blocked."],"exampleFix":"// before\nif (statusCode != 200 || body.code !== 0 || body.req.code !== 0) throw new Error('获取热门评论失败')\n\n// after\nif (statusCode != 200 || !body || body.code !== 0 || !body.req || body.req.code !== 0) {\n  console.warn('tx getHotComment failed', { statusCode, code: body?.code, reqCode: body?.req?.code })\n  throw new Error('获取热门评论失败')\n}","handlingStrategy":"try-catch","validationCode":"function hasTxSongId(mInfo) {\n  return mInfo != null && (!!mInfo.songId || !!mInfo.songmid)\n}","typeGuard":"function isTxHotCommentResponse(body) {\n  return body != null && typeof body === 'object' && body.code === 0 && body.req != null && body.req.code === 0 && body.req.data != null\n}","tryCatchPattern":"try {\n  const result = await txComment.getHotComment(mInfo, page, limit)\n} catch (err) {\n  if (err.message === '获取热门评论失败') {\n    console.warn('QQ Music hot comments unavailable for', mInfo.songmid)\n    return { source: 'tx', comments: [], total: 0, page, limit, maxPage: 1 }\n  }\n  throw err\n}","preventionTips":["Log both body.code and body.req.code separately to identify which layer failed.","Keep the module/method strings updated to match the current QQ Music web client.","Update the User-Agent periodically to avoid bot-detection flagging.","Fall back to the legacy fcg_global_comment endpoint if musicu.fcg is blocked.","Retry with backoff for transient failures."],"tags":["tencent","qq-music","hot-comments","network","api-contract","https","anti-scraping"],"backgroundTag":null,"analyzedSha":"9c364b482e5621a1d38b50e8610d2fb974457e6e","analyzedAt":"2026-08-12T15:14:48.244Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}