lyswhut/lx-music-desktop · error · Error

${type} size type no match

Error message

${type} size type no match

What it means

Inside qualityFilter (utils.js:24). For each quality entry, an optional `size` field must be a string (e.g. '4.2'). If `size` is present and its typeof is not 'string', the entry's `type` is interpolated into the message ('<type> size type no match') and the whole play-music call aborts before types are returned.

Source

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

  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')
    if (val != null) {
      if (rule.types && !rule.types.includes(typeof val)) throw new Error(rule.key + ' type no match')
      if (rule.max && String(val).length > rule.max) throw new Error(rule.key + ' max length no match')
      if (rule.min && String(val).length > rule.min) throw new Error(rule.key + ' min length no match')
    }
    newData[rule.key] = val

View on GitHub (pinned to 9c364b482e)

Solutions

  1. Have the sender emit `size` as a string consistently.
  2. Normalize entries before qualityFilter: coerce non-null size with String(size).
  3. Broaden the check to accept numbers and convert them, if both shapes are legitimate.
  4. Reject the offending entry and continue rather than failing the entire list.

Example fix

// before
    if (size != null && typeof size != 'string') throw new Error(type + ' size type no match')

// after - coerce instead of throw, preserving the string contract
    if (size != null && typeof size != 'string') size = String(size)
Defensive patterns

Strategy: validation

Validate before calling

const normalizeQualityTypes = (types) =>
  types.map(t => (t.size != null && typeof t.size !== 'string') ? { ...t, size: String(t.size) } : t)
// before qualityFilter:
musicInfo.types = normalizeQualityTypes(musicInfo.types)

Type guard

const isQualityEntry = (e) =>
  e != null && typeof e === 'object' && typeof e.type === 'string' &&
  (e.size == null || typeof e.size === 'string')

Try / catch

try {
  musicInfo.types = qualityFilter(musicInfo.source, musicInfo.types)
} catch (e) {
  errorDialog(e.message)
}

Prevention

When it happens

Trigger: A play-music deep link whose musicInfo.types array contains an entry like {type:'320k', size:4.2} (number) or {type:'flac', size:{...}} instead of size:'4.2'. qualityFilter is called from useMusicAction.js:136 after the source switch.

Common situations: The sender serializes size as a JSON number rather than a string; schema drift between sender and receiver; a manually constructed link with the wrong primitive.

Related errors


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