{"record":{"id":"d75d52b752cd59b2","repo":"lyswhut/lx-music-desktop","slug":"error-d75d52","errorCode":null,"errorMessage":"获取热门评论失败","messagePattern":"获取热门评论失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderer/utils/musicSdk/kw/comment.js","lineNumber":38,"sourceCode":"    return {\n      source: 'kw',\n      comments: this.filterComment(body.comments),\n      total,\n      page,\n      limit,\n      maxPage: Math.ceil(total / limit) || 1,\n    }\n  },\n  async getHotComment({ songmid }, page = 1, limit = 100) {\n    if (this._requestObj2) this._requestObj2.cancelHttp()\n\n    const _requestObj2 = httpFetch(`http://ncomment.kuwo.cn/com.s?f=web&type=get_rec_comment&aapiver=1&prod=kwplayer_ar_10.5.2.0&digest=15&sid=${songmid}&start=${limit * (page - 1)}&msgflag=1&count=${limit}&newver=3&uid=0`, {\n      headers: {\n        'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9;)',\n      },\n    })\n    const { body, statusCode } = await _requestObj2.promise\n    if (statusCode != 200 || body.code != '200') throw new Error('获取热门评论失败')\n    // console.log(body)\n\n    const total = body.hot_comments_counts\n    return {\n      source: 'kw',\n      comments: this.filterComment(body.hot_comments),\n      total,\n      page,\n      limit,\n      maxPage: Math.ceil(total / limit) || 1,\n    }\n  },\n  filterComment(rawList) {\n    if (!rawList) return []\n    return rawList.map(item => {\n      return {\n        id: item.id,\n        text: item.msg,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/lyswhut/lx-music-desktop/blob/9c364b482e5621a1d38b50e8610d2fb974457e6e/src/renderer/utils/musicSdk/kw/comment.js#L20-L56","documentation":"Thrown by Kuwo's getHotComment when the recommended/hot comment API at http://ncomment.kuwo.cn/com.s (type=get_rec_comment) returns a non-200 HTTP status or body.code is not '200'. Structurally identical to error 40 but targets hot/rec comments. Uses the same plain-http endpoint and the same loose-equality guard, so it shares all transport and contract fragility.","triggerScenarios":"Calling getHotComment({ songmid }, page, limit) where the song has no hot/recommended comments (Kuwo returns a non-200 body.code). Network interference with ncomment.kuwo.cn. A cancelled or rate-limited request. The same songmid that works for regular comments may return no hot comments.","commonSituations":"Songs with low popularity have no recommended comments, so Kuwo returns a non-200 code. ISP-level HTTP interception. The app's proxy configuration routes Kuwo traffic through a tunnel that strips headers.","solutions":["Distinguish 'no hot comments' from 'API error' by logging body.code and statusCode; if body.code indicates empty results, return an empty list instead of throwing.","Verify songmid validity before calling getHotComment.","Retry with backoff for transient failures.","Test the endpoint URL directly with curl using the Dalvik User-Agent to check if Kuwo changed the contract."],"exampleFix":"// before\nif (statusCode != 200 || body.code != '200') throw new Error('获取热门评论失败')\n\n// after\nif (statusCode != 200 || !body || body.code != '200') {\n  console.warn('kw getHotComment failed', { statusCode, code: body?.code })\n  if (body?.code && body.code !== '200') return { source: 'kw', comments: [], total: 0, page, limit, maxPage: 1 }\n  throw new Error('获取热门评论失败')\n}","handlingStrategy":"fallback","validationCode":"function canFetchHotComments(songmid) {\n  return typeof songmid === 'string' && songmid.length > 0\n}","typeGuard":"function isKwHotCommentResponse(body) {\n  return body != null && typeof body === 'object' && typeof body.code !== 'undefined'\n}","tryCatchPattern":"try {\n  const result = await kwComment.getHotComment({ songmid }, page, limit)\n} catch (err) {\n  if (err.message === '获取热门评论失败') {\n    console.warn('Kuwo hot comments unavailable for', songmid)\n    return { source: 'kw', comments: [], total: 0, page, limit, maxPage: 1 }\n  }\n  throw err\n}","preventionTips":["Treat 'no hot comments' as a valid empty result, not an error.","Fall back to regular comments if hot comments are unavailable.","Log body.code to distinguish empty-results from genuine API errors.","Validate songmid before calling."],"tags":["kuwo","hot-comments","network","api-contract","http"],"backgroundTag":null,"analyzedSha":"9c364b482e5621a1d38b50e8610d2fb974457e6e","analyzedAt":"2026-08-12T15:14:48.244Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}