{"record":{"id":"0a5dfb989df57dea","repo":"lyswhut/lx-music-desktop","slug":"error-0a5dfb","errorCode":null,"errorMessage":"获取热门评论失败","messagePattern":"获取热门评论失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/utils/musicSdk/wy/comment.js","lineNumber":171,"sourceCode":"    const id = 'R_SO_4_' + songmid\n    page = page - 1\n\n    const _requestObj2 = httpFetch(`https://music.163.com/weapi/v1/resource/hotcomments/${id}`, {\n      method: 'post',\n      headers: {\n        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',\n        origin: 'https://music.163.com',\n        Refere: 'http://music.163.com/',\n      },\n      form: weapi({\n        rid: id,\n        limit,\n        offset: limit * page,\n        beforeTime: Date.now().toString(),\n      }),\n    })\n    const { body, statusCode } = await _requestObj2.promise\n    if (statusCode != 200 || body.code !== 200) throw new Error('获取热门评论失败')\n    const total = body.total ?? 0\n    return { source: 'wy', comments: this.filterComment(body.hotComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }\n  },\n  filterComment(rawList) {\n    return rawList.map(item => {\n      let data = {\n        id: item.commentId,\n        text: item.content ? applyEmoji(item.content) : '',\n        time: item.time ? item.time : '',\n        timeStr: item.time ? dateFormat2(item.time) : '',\n        location: item.ipLocation?.location,\n        userName: item.user.nickname,\n        avatar: item.user.avatarUrl,\n        userId: item.user.userId,\n        likedCount: item.likedCount,\n        reply: [],\n      }\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/lyswhut/lx-music-desktop/blob/9c364b482e5621a1d38b50e8610d2fb974457e6e/src/renderer/utils/musicSdk/wy/comment.js#L153-L189","documentation":"Thrown by Netease's getHotComment when the hot comment endpoint at https://music.163.com/weapi/v1/resource/hotcomments/{id} returns non-200 or body.code !== 200. Uses weapi encryption. Notably, page is decremented by 1 before use (page = page - 1), and beforeTime is set to Date.now() (requesting hot comments before 'now', which is the same every call). Reads body.total and body.hotComments. The id is constructed as 'R_SO_4_' + songmid.","triggerScenarios":"The weapi encryption is broken. The song has no hot comments (body.code may still be 200 but body.hotComments is undefined, causing a downstream crash in filterComment). Rate-limiting or IP-banning. The songmid is invalid so 'R_SO_4_' + songmid is a non-existent thread.","commonSituations":"Same weapi key rotation issue as error 53. Non-CN IP blocking. beforeTime set to current time means it always requests the same window — if the song has no hot comments in that window, the result is always empty. body.total ?? 0 handles missing total, but body.hotComments undefined would crash filterComment.","solutions":["Log body.code and statusCode to diagnose encryption vs. rate-limiting.","Guard body.hotComments before passing to filterComment (it may be undefined when there are no hot comments).","Verify the weapi encryption is current.","Use a CN proxy if running from outside China.","Retry with backoff for transient failures."],"exampleFix":"// before\nif (statusCode != 200 || body.code !== 200) throw new Error('获取热门评论失败')\nconst total = body.total ?? 0\nreturn { source: 'wy', comments: this.filterComment(body.hotComments), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }\n\n// after\nif (statusCode != 200 || !body || body.code !== 200) {\n  console.warn('wy getHotComment failed', { statusCode, code: body?.code })\n  throw new Error('获取热门评论失败')\n}\nconst total = body.total ?? 0\nreturn { source: 'wy', comments: this.filterComment(body.hotComments || []), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }","handlingStrategy":"try-catch","validationCode":"function hasWySongmid({ songmid }) {\n  return typeof songmid === 'string' && songmid.length > 0\n}","typeGuard":"function isWyHotCommentResponse(body) {\n  return body != null && typeof body === 'object' && body.code === 200 && Array.isArray(body.hotComments)\n}","tryCatchPattern":"try {\n  const result = await wyComment.getHotComment({ songmid }, page, limit)\n} catch (err) {\n  if (err.message === '获取热门评论失败') {\n    console.warn('Netease hot comments unavailable for', songmid)\n    return { source: 'wy', comments: [], total: 0, page, limit, maxPage: 1 }\n  }\n  throw err\n}","preventionTips":["Guard body.hotComments against undefined before passing to filterComment.","Keep weapi encryption keys updated.","Use a CN proxy if running from outside China.","Log body.code and body.msg to diagnose.","Note that page is decremented internally (page = page - 1), so pass 1-based page numbers."],"tags":["netease","hot-comments","network","api-contract","weapi-encryption","https","rate-limiting"],"backgroundTag":null,"analyzedSha":"9c364b482e5621a1d38b50e8610d2fb974457e6e","analyzedAt":"2026-08-12T15:14:48.244Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}