lyswhut/lx-music-desktop · error · Error

Source no match

Error message

Source no match

What it means

The centralized source allowlist check in utils.js:18. `sources` enumerates the five supported providers ['kw','kg','tx','wy','mg']; sourceVerify throws 'Source no match' when the deep link's source isn't on the list. It is called by both songlist handlers (useSonglistAction.js:46 and :82) before dataVerify runs.

Source

Thrown at src/renderer/core/useApp/useDeeplink/utils.js:18

import { useI18n } from '@renderer/plugins/i18n'
import { dialog } from '@renderer/plugins/Dialog'

export const useDialog = () => {
  const t = useI18n()
  const errorDialog = message => {
    dialog({
      message: `${t('deep_link__handle_error_tip', { message })}`,
      confirmButtonText: t('ok'),
    })
  }

  return errorDialog
}

export const sources = ['kw', 'kg', 'tx', 'wy', 'mg']
export const sourceVerify = source => {
  if (!sources.includes(source)) throw new Error('Source no match')
}

export const qualitys = ['128k', '320k', 'flac', 'flac24bit']
export const qualityFilter = (source, types) => {
  types = types.filter(({ type }) => qualitys.includes(type)).map(({ type, size, hash }) => {
    if (size != null && typeof size != 'string') throw new Error(type + ' size type no match')
    if (source == 'kg' && typeof hash != 'string') throw new Error(type + ' hash type no match')
    return hash == null ? { type, size } : { type, size, hash }
  })
  if (!types.length) throw new Error('quality no match')
  return types
}

export const dataVerify = (rules, data) => {
  const newData = {}
  for (const rule of rules) {
    const val = data[rule.key]
    if (rule.required && val == null) throw new Error(rule.key + ' missing')

View on GitHub (pinned to 9c364b482e)

Solutions

  1. If a new provider is genuinely supported, append it to the `sources` array in utils.js (the single source of truth).
  2. Ensure the source field is populated from paths[0] or data.source before sourceVerify is called.
  3. Catch the throw upstream and show a user-facing 'unsupported source' dialog via useDialog().
  4. Reuse `sources` everywhere instead of re-declaring the list, so additions propagate.

Example fix

// before
export const sourceVerify = source => {
  if (!sources.includes(source)) throw new Error('Source no match')
}

// after - include the value and the allowed set in the message
export const sourceVerify = source => {
  if (!sources.includes(source)) {
    throw new Error(`Source no match: '${source}'. Supported: ${sources.join(', ')}`)
  }
}
Defensive patterns

Strategy: validation

Validate before calling

import { sources } from './utils'
if (!sources.includes(info?.source)) {
  showErrorDialog(`Unsupported source: ${info?.source}. Must be one of ${sources.join(', ')}`)
  return
}

Type guard

import { sources } from './utils'
const isKnownSource = (s) => typeof s === 'string' && sources.includes(s)

Try / catch

try {
  sourceVerify(info.source)
  // ... proceed with handler
} catch (e) {
  errorDialog(e.message)
}

Prevention

When it happens

Trigger: Any deep link that reaches sourceVerify with a source outside kw/kg/tx/wy/mg — including null, undefined, or '' (since the default songlistInfo initializes source to null and only assigns from paths/data).

Common situations: A new provider not yet registered in the allowlist; the source field not set during parsing (so it stays null); a test or placeholder link using a fake source code.

Related errors


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