lyswhut/lx-music-desktop · error · Error

Unknown source: ${musicInfo.source}

Error message

Unknown source: ${musicInfo.source}

What it means

Thrown by filterInfoByPlayMusic's switch in useMusicAction.js:134 when a 'play music' deep link carries a `source` that is not one of the five handled providers (kw, kg, tx, wy, mg). The default branch rejects the payload before it can be normalized and queued for playback. The unsupported value is interpolated into the message for diagnostics.

Source

Thrown at src/renderer/core/useApp/useDeeplink/useMusicAction.js:134

      case 'mg':
        musicInfo = dataVerify([
          { key: 'name', types: ['string'], required: true, max: 200 },
          { key: 'singer', types: ['string'], required: true, max: 200 },
          { key: 'source', types: ['string'], required: true },
          { key: 'songmid', types: ['string', 'number'], max: 64, required: true },
          { key: 'img', types: ['string'], max: 1024 },
          { key: 'albumId', types: ['string', 'number'], max: 64 },
          { key: 'interval', types: ['string'], max: 64 },
          { key: 'albumName', types: ['string'], max: 200 },
          { key: 'types', types: ['object'], required: true },

          { key: 'copyrightId', types: ['string', 'number'], required: true, max: 64 },
          { key: 'lrcUrl', types: ['string'], max: 1024 },
          { key: 'trcUrl', types: ['string'], max: 1024 },
          { key: 'mrcUrl', types: ['string'], max: 1024 },
        ], musicInfo)
        break
      default: throw new Error('Unknown source: ' + musicInfo.source)
    }
    musicInfo.types = qualityFilter(musicInfo.source, musicInfo.types)
    return musicInfo
  }

  return ({ data: _musicInfo }) => {
    _musicInfo = filterInfoByPlayMusic(_musicInfo)

    let musicInfo = {
      ..._musicInfo,
      singer: decodeName(_musicInfo.singer),
      name: decodeName(_musicInfo.name),
      albumName: decodeName(_musicInfo.albumName),
      otherSource: null,
      _types: {},
      typeUrl: {},
    }
    for (const type of musicInfo.types) {

View on GitHub (pinned to 9c364b482e)

Solutions

  1. If a new provider was genuinely added to the app, add a case branch with its dataVerify rules in the switch AND register it in `sources` in utils.js.
  2. Call sourceVerify(musicInfo.source) before the switch so unknown sources are rejected at a single chokepoint with a consistent message.
  3. Wrap the dispatcher at the deeplink router in try-catch and route the message through useDialog() rather than letting it throw uncaught.
  4. If the link came from path parsing, confirm the source segment was extracted into the correct slot before handlePlayMusic is invoked.

Example fix

// before
    default: throw new Error('Unknown source: ' + musicInfo.source)

// after - reject earlier with the shared allowlist
import { sources, sourceVerify } from './utils'
// at the top of filterInfoByPlayMusic, before the switch:
if (!sources.includes(musicInfo.source)) {
  throw new Error(`Unknown source: ${musicInfo.source}. Supported: ${sources.join(', ')}`)
}
Defensive patterns

Strategy: validation

Validate before calling

import { sources } from './utils'
const isKnownSource = (s) => sources.includes(s)
// before calling handlePlayMusic(info):
if (!isKnownSource(info?.source)) {
  showErrorDialog(`Unsupported music source: ${info?.source}`)
  return
}

Type guard

import { sources } from './utils'
const isMusicSource = (s) => typeof s === 'string' && sources.includes(s)
// usage: if (isMusicSource(musicInfo.source)) { ... }

Try / catch

// at the deeplink router, around the music dispatcher:
try {
  await handleMusicAction(action, info)
} catch (e) {
  errorDialog(e.message) // surfaces via useDialog()
}

Prevention

When it happens

Trigger: A deep link whose musicInfo.source is anything outside kw/kg/tx/wy/mg — e.g. a 'sp' (Spotify-like) source, an empty string, or undefined after path/data parsing — reaches the switch at useMusicAction.js:87-134 and falls through to default at line 134.

Common situations: A third-party app or share sheet emits a link with a provider code this build doesn't support; protocol version skew where a newer sender knows a source this receiver lacks; the source field dropped during URL→data conversion so it is undefined.

Related errors


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