{"record":{"id":"49ebacd5de1c7586","repo":"lyswhut/lx-music-desktop","slug":"error-49ebac","errorCode":null,"errorMessage":"歌手不存在","messagePattern":"歌手不存在","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/renderer/utils/musicSdk/kg/singer.js","lineNumber":10,"sourceCode":"import { getMusicInfosByList } from './musicInfo'\nimport { createHttpFetch } from './util'\n\nexport default {\n  /**\n   * 获取歌手信息\n   * @param {*} id\n   */\n  getInfo(id) {\n    if (id == 0) throw new Error('歌手不存在') // kg源某些歌曲在歌手没被kg收录时返回的歌手id为0\n    return createHttpFetch(`http://mobiles.kugou.com/api/v5/singer/info?singerid=${id}`).then(body => {\n      if (!body) throw new Error('get singer info faild.')\n\n      return {\n        source: 'kg',\n        id: body.singerid,\n        info: {\n          name: body.singername,\n          desc: body.intro,\n          avatar: body.imgurl.replace('{size}', 480),\n          gender: body.grade === 1 ? 'man' : 'woman',\n        },\n        count: {\n          music: body.songcount,\n          album: body.albumcount,\n        },\n      }\n    })","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/lyswhut/lx-music-desktop/blob/9c364b482e5621a1d38b50e8610d2fb974457e6e/src/renderer/utils/musicSdk/kg/singer.js#L1-L28","documentation":"Kugou singer.getInfo in kg/singer.js:10 guards `if (id == 0) throw '歌手不存在'` (singer does not exist). KG returns singerid 0 for tracks whose artist isn't registered with Kugou; getInfo refuses to fetch a meaningless id=0 singer profile rather than returning junk. Called when the UI requests a singer's detail/avatar/description.","triggerScenarios":"getInfo is invoked with a singer id of exactly 0 — typically derived from a song whose `singerid` KG populated with 0 because the artist is unregistered or unknown.","commonSituations":"An obscure or unregistered artist; KG data-quality issues; a song object whose singer field was synthesized without a real id; id parsing producing 0 from a missing field.","solutions":["Check for a falsy/zero singer id before calling getInfo and hide the singer-detail section in the UI.","Fall back to a generic 'unknown artist' state instead of invoking the API.","Handle the throw at the call site and show 'artist information unavailable'.","Filter out id==0 songs from singer-navigation affordances."],"exampleFix":"// before\n  getInfo(id) {\n    if (id == 0) throw new Error('歌手不存在')\n    ...\n  }\n\n// after - guard at the call site, no throw\nconst info = singerId && singerId != 0\n  ? await kgSinger.getInfo(singerId)\n  : null\nif (!info) renderUnknownArtist()","handlingStrategy":"validation","validationCode":"const isResolvableSinger = (id) => id != null && Number(id) !== 0\nif (!isResolvableSinger(singerId)) {\n  // hide singer detail section, do not call getInfo\n  renderUnknownArtist()\n  return\n}","typeGuard":"const isResolvableSingerId = (id) =>\n  (typeof id === 'number' && id !== 0) || (typeof id === 'string' && id !== '' && id !== '0')","tryCatchPattern":"let info = null\ntry {\n  if (singerId != 0) info = await kgSinger.getInfo(singerId)\n} catch (e) {\n  info = null // render 'artist unavailable'\n}","preventionTips":["Filter out singerid==0 songs from 'view artist' entry points.","Treat a 0 singer id as 'unknown artist' in the UI rather than triggering the API.","Validate the id at the call site since getInfo will not fetch for id==0."],"tags":["kugou","singer","data-quality","guard-clause"],"backgroundTag":null,"analyzedSha":"9c364b482e5621a1d38b50e8610d2fb974457e6e","analyzedAt":"2026-08-12T15:14:48.244Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}