lyswhut/lx-music-desktop · warning · Error

歌手不存在

Error message

歌手不存在

What it means

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.

Source

Thrown at src/renderer/utils/musicSdk/kg/singer.js:10

import { getMusicInfosByList } from './musicInfo'
import { createHttpFetch } from './util'

export default {
  /**
   * 获取歌手信息
   * @param {*} id
   */
  getInfo(id) {
    if (id == 0) throw new Error('歌手不存在') // kg源某些歌曲在歌手没被kg收录时返回的歌手id为0
    return createHttpFetch(`http://mobiles.kugou.com/api/v5/singer/info?singerid=${id}`).then(body => {
      if (!body) throw new Error('get singer info faild.')

      return {
        source: 'kg',
        id: body.singerid,
        info: {
          name: body.singername,
          desc: body.intro,
          avatar: body.imgurl.replace('{size}', 480),
          gender: body.grade === 1 ? 'man' : 'woman',
        },
        count: {
          music: body.songcount,
          album: body.albumcount,
        },
      }
    })

View on GitHub (pinned to 9c364b482e)

Solutions

  1. Check for a falsy/zero singer id before calling getInfo and hide the singer-detail section in the UI.
  2. Fall back to a generic 'unknown artist' state instead of invoking the API.
  3. Handle the throw at the call site and show 'artist information unavailable'.
  4. Filter out id==0 songs from singer-navigation affordances.

Example fix

// before
  getInfo(id) {
    if (id == 0) throw new Error('歌手不存在')
    ...
  }

// after - guard at the call site, no throw
const info = singerId && singerId != 0
  ? await kgSinger.getInfo(singerId)
  : null
if (!info) renderUnknownArtist()
Defensive patterns

Strategy: validation

Validate before calling

const isResolvableSinger = (id) => id != null && Number(id) !== 0
if (!isResolvableSinger(singerId)) {
  // hide singer detail section, do not call getInfo
  renderUnknownArtist()
  return
}

Type guard

const isResolvableSingerId = (id) =>
  (typeof id === 'number' && id !== 0) || (typeof id === 'string' && id !== '' && id !== '0')

Try / catch

let info = null
try {
  if (singerId != 0) info = await kgSinger.getInfo(singerId)
} catch (e) {
  info = null // render 'artist unavailable'
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of lyswhut/lx-music-desktop@9c364b482e (2026-08-12). Data as JSON: /api/errors/49ebacd5de1c7586. Report an issue: GitHub.